The CSS reference
"display" - css property (v. css 1)
- This property describes how/if an element is displayed on the canvas.
- Initial value: inline (in CSS 2), block (in CSS 1)
- The property is not inherited
- HTML usage: all elements
-
Browsers that support the display - property :
Possible display values:
display value | Comments | CSS |
---|---|---|
block | This value causes an element to generate a block box. | 1 |
inline | This value causes an element to generate a block box, which itself is flowed as a single inline box, similar to a replaced element. The inside of an inline-block is formatted as a block box, and the element itself is formatted as an inline replaced element. | 1 |
list-item | A value of 'list-item' is similar to 'block' except that a list-item marker is added. In HTML, 'LI' will typically have this value.. | 1 |
none | This value causes an element to generate no boxes in the formatting structure. Descendant elements do not generate any boxes either; this behavior cannot be overridden by setting the 'display' property on the descendants. | 1 |
marker | This value declares generated content before or after a box to be a marker. This value should only be used with ':before' and ':after' pseudo-elements attached to block-level elements. In other cases, this value is interpreted as 'inline'. | 2 |
run-in compact |
This value creates either block or inline boxes, depending on context. Properties apply to run-in boxes based on their final status (inline-level or block-level). | 2 |
table, inline-table, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, and table-caption |
These values cause an element to behave like a table element. | 2 |
The three properties that affect box generation and layout interact as follows:
display value | position value | float value | Comments |
---|---|---|---|
'none' | Based on display value UA should ignore this | Based on display value UA should ignore this | The element generates no box |
Based on position value: se table below. | 'absolute' or 'fixed' | Based on position computed value to be 'none' | The position of the box will be determined by the 'top' , 'right' , 'bottom' and 'left' properties and the box's containing block. |
Computed value: se table below. | 'static' or 'relative' | other than 'none' | The box is floated. |
Computed value: se table below. | The element is the root element. | ||
Apply as specified. | All other cases. |
Computed value based on specified value for display property under certain conditions:
Specified value | Computed value |
---|---|
inline-table | table |
inline, run-in, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, table-caption, inline-block | block |
others | same as specified |
Property "display" example:
<!DOCTYPE HTML >
<html>
<head>
<script type="text/javascript">
function changeDisplay(displaytype) {
document.getElementById("h1").style.display=displaytype;
document.getElementById("b1").style.display=displaytype;
}
</script>
</head>
<body >
<h1 id="h1">CSS Selectors</h1>
<blockquote id="b1">One of the primary advantages of
CSSparticularly to designersis its ability to
easily apply a set of styles to all elements
of the same type. Unimpressed? Consider this:
by editing a single line of CSS, you can change
the colors of all your headings.</blockquote>
<div>
<input type="button" onclick="changeDisplay('inline')"
value="Header and paragraph to inline" />
<input type="button" onclick="changeDisplay('block')"
value="Header and paragraph to block" />
<input type="button" onclick="changeDisplay('none')"
value="Header and paragraph to nonee" />
</div>
</body>
</html>
Javascript access:
// To SET values ([o] is the target object)
[o].style.display="display value"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:;
var value=cStyle.display;
© 2010 by Finnesand Data.
All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the
correctness in the pages or source codes.
The risk of using this web-site pages or any program
codes from this website is entirely at the individual user.