Auto width on a block element. : width « CSS « HTML / CSS






Auto width on a block element.

   
<!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>width</title>
<style type='text/css'>
div {
    padding: 4px;
    background: yellow;
}
</style>


    </head>
    <body>
        <div>
            Auto width on a block element.
        </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.Set the width for the full page
21.width sets the width of the element. width:auto is the default value.
22.Default width
23.width:auto is the default.
24.width sets the width of an element's inner box.
25.Set width to auto for an anchor with LI under UL in a DIV
26.static width and centered
27.Set the total width to 50%
28.width: auto
29.width, height: auto
30.width, height: percentage, and html body no margin
31.width setting with more content than width
32.A div with auto width expands horizontally filling the whole available area.
33.Margin and width
34.Use width:auto to stretch the width of a block to the sides of its parent.
35.Aligned and Offset Static Table
36.Left-aligned Shrinkwrapped Table
37.Centered Shrinkwrapped Table
38.This div stretches across the whole window
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