A CSS selector that matches all elements that may contain text?

Is there a way to select items that may contain text?

Something like that:

*:text {
   font-size: 12px;
}

I want to use it for mine reset.css, but I can’t find a way to do this, so now I use this code:

* {
   font-size: 12px;
}

This solution works for all text elements (e.g. STRONG, P, A, etc.), but also applies this style to non-text elements such as IMG, OBJECT and others.

So I'm wondering if there is another solution for setting CSS properties for all text elements, but nothing else.

+4
source share
3 answers

img, object .., css.

:empty (). , , , , . , img, , (sic!) p. .

+3

, , , css. , , .

, ,

* {
   font-size: 12px;
}

dom. , , , html . , , .

html, body { /* this allows the children to inherit this style */
   font-size: 12px;
}

body * { /* assigns this style to every tag inside of your body tag */
    font-size: 12px;
}

p, span, a, etc { /* you decided what tags would most likely contain text to apply that style */
    font-size: 12px;
}

* { /* the worst option, applying that style to every tag */
    font-size: 12px;
}
+2

All Articles