This page has been translated into Brazilian Portuguese, Italian, and German.
The display property lets you define how a certain HTML element should be displayed.
See also the W3C specs.
| Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
| Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
| Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
| No | Incom |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||
|
|||||||||||||||||
| No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||
| No | Yes | No | Incor |
Yes | Yes | Yes | To be tested | ||||||||||
|
|||||||||||||||||
| No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||
Safari 3 and Chrome 1 require elements with |
|||||||||||||||||
| Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
display: block means that the element is displayed as a block, as paragraphs and headers have always been. A block has
some whitespace above and below it and tolerates no HTML elements next to it, except when ordered otherwise (by
adding a float declaration to another element, for instance).
display: inline means that the element is displayed inline, inside the current block on the same line. Only
when it's between two blocks does the element form an 'anonymous block', that however has the smallest possible
width.
display: none means that the element is not displayed at all (so you won't see it in the example either).
An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a block.
span (and not div) with display: inline-block; width: 10emIt's supposed to work like this (Opera):
The real use of this value is when you want to give an inline element a width. In some circumstances some browsers
don't allow a width on a real inline element, but if you switch to display: inline-block you are allowed
to set a width.
display: list-item means that the element is displayed as a list-item, which mainly means that it has
a bullet in front of it (like an UL), except in IE 5 on Mac where it gets a number (like an OL). The numbers
are buggy: all previous LI's in the page count as one, so this example starts with number 5 (the screenshot was made
before I inserted my compatibility-LI's).
display: run-in definition from
W3C:
"If a block box (that does not float and is not absolutely positioned) follows the run-in
box, the run-in box becomes the first inline box of the block box.
Otherwise, the run-in box becomes a block box."
Question: Why would you want to do this?
Anyway, Opera is the only browser to really support this. It removes the padding-top and -bottom of the
run-in box, though W3C doesn't say it should.
IE 5 Mac reacts by giving the run-in box a slight
indent. I have no idea why.
It's supposed to work like this (Opera):
display: table tells the element to display as a table. Nested elements should be displayed as
table-row and table-cell, mimicking the good old TR's and TD's. There's also a
display: table-column but it should show nothing at all, only serving for style information like
a COL does. I'm not sure exactly how this works.
It's supposed to look like this (Firefox 1.5):
However, Safari insists on the elements with display: table and display: table-row:
Play around with some display declarations below.