XML technologies / CSS / Advanced websites with CSS / A simple CSS layout / Positioning page elements / The display property

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

Before turning to positioning elements with CSS, let us examine the property display, which can have a considerable effect on page layout.

The display property determines how the browser displays an element: as a block, list item, line of text or another form. CSS2 specifies 17 different values, but browsers currently support only six, of which four are really important. A complete reference for the property display is available under CSS property reference.

The six possible values of the property display are:

The default value of the property display depends on the element type to which it is assigned. Block elements such as p, h1 and div automatically receive the value block, while inline elements such as strong, code and span receive the value inline unless another value is explicitly assigned. List items have their own value, list-item, just as table header and footer rows have the values table-footer-group and table-header-group. Changing an element’s display values sometimes produces interesting and useful results. Later, we will see how display: inline displays a list horizontally.

The value none can be even more useful. It makes the browser disregard the element: it is neither displayed nor given a placeholder in the layout, as it would be with visibility: hidden. This distinguishes the property display: none from the property visibility: hidden, which reserves space for the hidden element.

  

 

 

 

back to top