• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 3. Selectors in Action > Universal Selectors

Universal Selectors

Universal selectors are used to select any element. For example, to set the margins and padding on every element to 0, * can be used as shown in Listing 3.9.

Listing 3.9. CSS Code Containing the Universal Selector

*
{
     margin: 0;
     padding: 0;
}

Universal selectors also can be used to select all elements within another element as shown in Listing 3.10. This will select any element inside the <p> element.

Listing 3.10. CSS Code Containing the Universal Selector Within the <p> Element

p *
{
     color: red;
}

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint