This div stretches across the whole window : width « CSS « HTML / CSS






This div stretches across the whole window

  


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title></title>
        <style type='text/css' media='all'>

          body {
            margin: 0;
          }
        
          div {
            width: 100%;
            color: white;
            background: black;
          }
        </style>
    </head>
    <body>
            <div>
              This div stretches across the whole window.
            </div>
    </body>
</html>

   
  








Related examples in the same category

1.'width' Example
2.width: 250px
3.width: 1in
4.width: 96px;
5.width: 12em;
6.width: 192px;
7.width: 100%;
8.When all four offset properties are specified on the same element both width and height are implied.
9.width: 150px
10.width and height
11.width and height absolute positioning
12.width and height: auto
13.width and height: auto for table
14.width and height percentage
15.width: 200px; height: 300px;
16.more content than width
17.floats and percentage width
18.Set width for td
19.This text is chopped off
20.Auto width on a block element.
21.Set the width for the full page
22.width sets the width of the element. width:auto is the default value.
23.Default width
24.width:auto is the default.
25.width sets the width of an element's inner box.
26.Set width to auto for an anchor with LI under UL in a DIV
27.static width and centered
28.Set the total width to 50%
29.width: auto
30.width, height: auto
31.width, height: percentage, and html body no margin
32.width setting with more content than width
33.A div with auto width expands horizontally filling the whole available area.
34.Margin and width
35.Use width:auto to stretch the width of a block to the sides of its parent.
36.Aligned and Offset Static Table
37.Left-aligned Shrinkwrapped Table
38.Centered Shrinkwrapped Table
39.Fixed Width CSS
40.width more content than width
41.width and height with percentage and html body no margin
42.floats and percentage width 2
43.height sets the height of an element's inner box.
44.height:auto is the default
45.width, height: percentage
46.height: size an element by assigning pixels, ems, a percentage
47.Percentages are more flexible because they can scale to the viewport.
48.height:100% stretches an element to the height of its parent.
49.height sets the height of the element.
50.height: 150px
51.Height and overflow
52.width: auto and height: 200px
53.width: 100% and height: 100%
54.width: 200px and height: auto