Stylesheet
#firstblock { background: #000; float: left; }
.genblock { background: #006699; float: left; }
HTML
<div id="firstblock"></div>
<div class="genblock"></div>
How you should do it
Or
Stylesheet
.left { float: left; }
#firstblock { background: #000; }
.genblock { background: #006699; }
HTML
<div id="firstblock" class="left"></div>
<div class="genblock left"></div>
The element must float on the right side of its containing block. The element must not float. The element must float on the start side of its containing block. That is the left side with ltr scripts, and the right side with rtl scripts.
left : floats the element to the left of its container. right : floats the element to the right of its container.
Here is one way of doing it. The trick is to apply overflow: auto to the div , which starts a new block formatting context. The result is that the floated button is enclosed within the block area defined by the div tag. You can then add margins to the button if needed to adjust your styling.
The clear property can be specified with any of the following values: none (default): Floating elements are allowed on both sides of the cleared element. left: No floating elements are allowed on the left side of the cleared element. right: No floating elements are allowed on the right side of the cleared element.
You should not leak presentational information (CSS) to your data layer (HTML).
You should give your elements a class name that describes their purpose. Whether it floats or not is irrelevant in the HTML. You decide that in the CSS.
What if you had a class name such as blue
and then your clients say we now want all those things red?
<ul id="primary-menu">
....
</ul>
#primary-menu {
float: left;
color: #f00;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With