Use clear to start a new line : Block Elements « Style Basics « HTML / CSS






Use clear to start a new line

 



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
    <head>
        <title></title>
        <style rel='stylesheet' type='text/css'>

div#container {
    border: 1px solid black;
    margin: 0 20px;
    background: pink;
    padding: 5px;
}

div#float {
    text-align: center;
    float: left;
    width: 150px;
    height: 150px;
    border: 1px solid blue;
    background: gold;
}
div.content {
    background: yellow;
    border: 1px solid  purple;
}
div#clear {
    border: 1px solid red;
    background: orange;
    clear: both;
}        
        </style>
    </head>
    <body>
        <div id='container'>
            <div id='float'>
                Float text. 
            </div>
                Content text. 
            <div class='content'>
                Content text. 
            </div>
                Content text. 
            <div class='content'>
                Content text. 
            </div>
                Content text. 
            <div class='content'>
                Content text. 
            </div>
                Content text. 
            <div id='clear'>
                Clear text. 
            </div>
            <div>
                Another div.
            </div>
        </div>
    </body>
</html>

 








Related examples in the same category

1.DIV by default starts new line
2.Floating left block pushes siblings to the right
3.Align in a row one by one for floating blocks
4.Use margin to offset block
5.Align text block to the right with margin auto
6.Block being added one by one