Difference between #id and div#id

后端 未结 9 1815
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 04:52

I am new to css. Can someone help me in differentiating \"#test\" and \"div#test\"?

9条回答
  •  余生分开走
    2020-12-22 05:34

    The #id is Selects the element with id="firstname". It is one kind of CSS Selectors.

    Check all CSS Selectors at https://www.w3schools.com/cssref/css_selectors.asp

    There is a minor difference.

    When you use div#id it will only apply to #id that are attached to a div. Otherwise the rule is ignored.

    Hope it helps. Thanks

提交回复
热议问题