html - If the <div> Element Is Block Level Element How Could 2 divs Be Placed Next to Each Other -


this question has answer here:

according w3schools.com learnt element block level element (that is, browser display line break before , after it).

then how 2 divs placed next each other?

some code w3schools:

<!doctype html>    <html>       <body>           <div id="container" style="width:500px">              <div id="header" style="background-color:#ffa500;">                <h1 style="margin-bottom:0;">main title of web page</h1>          </div>           <div id="menu" style="background color:#ffd700;height:200px;width:100px;float:left;">             <b>menu</b><br>             html<br>             css<br>             javascript          </div>           <div id="content" style="background-color:#eeeeee;height:200px;width:400px;float:left;">content goes here          </div>           <div id="footer" style="background-color:#ffa500;clear:both;text-align:center;">copyright © w3schools.com          </div>           </div>       </body>    </html> 

"by default, block-level elements formatted differently inline elements. generally, block-level elements begin on new lines, inline elements not."

two block level elements start on new lines, can have them side side float property. in code, have piece in div style making them side side.

float: left; 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -