Universal

The Universal Selector is the * in CSS. Literally the asterisk character. It is essentially a type selector that matches any type. Type meaning an HTML tag like <div>, <body>, <button>, or literally any of the others.

A common use is in the universal reset, like this:

* {
  margin: 0;
  padding: 0;
}

There are times when using the universal selector is implied. For instance:

*.module {  }

is exactly the same as:

.module {  }

And in fact, the specificity of those is exactly the same, as the universal selector hold no specificity value at all.

The universal selector also is used with "universal namespaces". It's a bit weird, so I'll just let this simple demo speak for itself.

Other Resources

Browser Support

Chrome Safari Firefox Opera IE Android iOS
Any Any Any Any Any Any Any

Comments

  1. User Avatar
    manojhl123
    Permalink to comment#

    In wordpress TwentyThirteen theme i found this styling

    [class*="content"]:before

    It is used to clear the float
    but i don’t understand this type of styling does any one know how it works.

    what’s that [ ] signifies plz expalin the syntax

    • User Avatar
      Matt
      Permalink to comment#

      I think it’s pointing to any element with a class that begins with (*=) the word “content.”

    • User Avatar
      Dinu
      Permalink to comment#

      I think it’s pointing to any element with a class name that contains the word “content”, like content-wrap

    • User Avatar
      Zohaib Hassan
      Permalink to comment#

      This selector [class*=”content”] selects all elements that have a class attribute value that contains content. For example
      1 – hello-content
      2 – content-hello
      3 – hellocontenthello

      We can use [class$=”content”] to select elements that have a class attribute value that ends with content. For example
      1 – hello-content

      We can also use [class^=”content”] to select elements that have a class attribute value that begins with content. For example
      1 – content-hello

  2. User Avatar
    eyrty
    Permalink to comment#

    > rmniytrlykkleryklklernyl

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

Submit a Comment

icon-closeicon-emailicon-linkicon-menuicon-searchicon-tag