What does “body > *” mean in CSS?

后端 未结 6 1315
忘了有多久
忘了有多久 2021-02-18 21:39

I am trying to understand the CSS effects that jQTouch implements. http://www.jqtouch.com/

It has some CSS definitions that contain syntax like body > *<

相关标签:
6条回答
  • 2021-02-18 21:47

    * refers to all elements, and > means immediate child elements, so body > * means all immediate child elements of the body.

    It's probably a hack of some kind to refer to a particular browser, though I'm not familiar with it.

    0 讨论(0)
  • 2021-02-18 21:53

    * is a wildcard selector and simply matches all elements, so body > * will match all direct children of the body element.

    0 讨论(0)
  • body > * means "any element that is a direct child of the body element."

    Compare this to body *, which means "any element that is a descendant of the body element." So this would also match the <a> element in <body><p><a>...</a></p></body>, for example.

    0 讨论(0)
  • 2021-02-18 22:05

    The > character is a match indicator and the * is the match being indicated.

    So

    body > * 
    

    means to match any child of Body.

    http://www.w3.org/TR/CSS2/selector.html

    0 讨论(0)
  • body > * means "any direct child of the body tag", e.g. consider the following scenario

    <body>
        <h1>This will be affected by body > *</h1>
        <div>
            This also
            <p>This will not be affected, because it is not a direct child</p>
        </div>
    </body>
    
    0 讨论(0)
  • 2021-02-18 22:10

    The > means that only the following * (anything), which is the IMMEDIATE child of the body will be affected.

    So body > * basically means every immediate child of the body tag. body * means all tags inside the body tag, no matter the level.

    0 讨论(0)
提交回复
热议问题