Grow your CSS skills. Land your dream job.

using * selector for font-family declaration

  • # February 27, 2013 at 4:51 pm

    Was wondering why you never see font-family declaration under the * selector. Is there a reason to not do this?

    thanks

    # February 27, 2013 at 4:56 pm

    It’s just not necessary.

    By using [*] it’s applying the font property to every element (images etc) even though it might not need it.

    Attaching it to the [body] element sets it for all **text** on the page body.

    I’m not entirely sure but also I think using [*] is more specific than sub-elements of the body and so might override other settings.

    # February 27, 2013 at 5:11 pm

    thanks Paulie

    # February 27, 2013 at 5:22 pm

    @Paulie_D, * selector has no specificity at all but author styles always override user agent styles (no matter specificity).

    So setting your font-family using * will override the default monospace font of code elements etc. Anyway, as said it’s just not needed since font-family is inherited.

    http://www.w3.org/TR/CSS21/cascade.html

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".