re1man
re1man

Reputation: 2367

applying css to everything inside element

How do I apply a css property to everything inside an element.

Like if I have:

p
    {
         font:15px "Lucida Grande", Arial, sans-serif;
        padding-right:150px;
    }

<p>
<span>
<div>
</div>
</span>
</p>

Upvotes: 4

Views: 16541

Answers (1)

simshaun
simshaun

Reputation: 21466

You posted invalid HTML. Block-level elements such as <div> do not go inside of <p> tags, and especially not inside of inline elements such as a <span>.

Anyway, the CSS selector to match anything is *

p, p * {
    font: 15px 'Lucida Grande', Arial, sans-serif;
    padding-right: 150px;
}

Be careful using the * selector. It is "slow" when there are a lot of elements to match.

Upvotes: 16

Related Questions