Set an element's width equal to window's width - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Width

Description

Set an element's width equal to window's width

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
 </head> <!--  w w w  . j  av a2s . c om-->
 <body> 
  <div style="width:100%; padding: 20px;"> 
   <div style="width:100%; background:red">
     Test 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials