0

In css, what's the difference of two selector: * and html?

*{

}

and

html{

}

Do these two work differently?

kathy
  • 339
  • 6
  • 17

1 Answers1

2

the *{} selects all elements and all it's children elements where html{} only selects the <html> element

See example

html {
    border: solid 2px orange;
}

* {
    border: solid 2px green;
    font-size: 1.2em;
}
<ul>
  <li>one</li>
  <li>two</li>
  <li>three
  <ul>
    <li>one</li>
    <li>two</li>
    <li>three</li>
  </ul>
  </li>
</ul>

<p>lorem ipsum</p>

Now see even how the font gets bigger cause its em which will take the size from the previous element.

caramba
  • 21,963
  • 19
  • 86
  • 127