Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What CSS properties can be applied to which HTML elements

I'm looking for a source/spec that can tell me what CSS properties can applied to which HTML elements. For instance, the css property; "overflow". I know I can apply this to div, p, textarea but what other elements can I apply this too? Is there a spec somewhere I can reference?

like image 535
Tim Boland Avatar asked Feb 09 '09 16:02

Tim Boland


2 Answers

See http://www.w3.org/TR/CSS2/ and http://www.w3.org/TR/CSS/.

For example, regarding your question about the overflow property, see:

http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping, stating:

'overflow'
    Value:          visible | hidden | scroll | auto | inherit
    Initial:        visible
    Applies to:     block-level and replaced elements
    Inherited:      no
    Percentages:    N/A
    Media:          visual
like image 120
Aron Rotteveel Avatar answered Nov 15 '22 13:11

Aron Rotteveel


In the CSS processing model, every element has every property that is applicable to the target media type. For example, even the empty <br> element has the color property. But whether a property has an effect on the rendering of the element itself depends on the specific property and the context, in a manner that is described in applicable CSS specifications and drafts. It is usually described under an “Applies to” heading. There is no combined compilation of this, and the set of properties recognized by browsers varies considerably.

Even though a property “applies to” an element by the specifications, it need not have an actual effect. For example, border-color is irrelevant for the rendering of an element if its border-style is none or its border-width is 0. (The value may still matter if it is inherited by child elements.)

like image 27
Jukka K. Korpela Avatar answered Nov 15 '22 12:11

Jukka K. Korpela