HTML CSS examples for CSS Layout:Float
CSS float attribute for a sidebar
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> body {<!--from w ww. ja va 2s . c om--> background-color:Chartreuse; color:yellow; } #header { text-align:center; background-color:blue; padding:21px 0px 0px 0px; } #body { background-color:pink; border:6px inset OrangeRed; margin-left:11px; margin-right:21px; float:left; width:71%; padding:11px 6px 11px 0px; } #sidebar { background-color:grey; border:6px inset BlueViolet; padding:11px 6px 11px 0px; text-align:center; width:21%; height:100%; float:right; } p { line-height:161%; font-family:Verdana, Arial, Helvetica, sans-serif; Padding:6px 11px 6px 11px; } </style> </head> <body> <div id="body"> <h1 id="header">Lorem ip</h1> <p>Lorem ipsum <br> <br>Lorem ipsum d</p> <h2 style="text-align: center;">Lo</h2> <ol> <li></li> <li></li> </ol> <p style="text-align: center;">Lorem i<br>Lorem ipsum dolor si</p> </div> <div id="sidebar"> <h1>Lorem ips</h1> <p>Lorem ipsum dol</p> </div> </body> </html>