Why does CSS work with fake elements?

前端 未结 19 716
野的像风
野的像风 2020-11-28 01:21

In my class, I was playing around and found out that CSS works with made-up elements.

Example:

19条回答
  •  情深已故
    2020-11-28 01:49

    ...I simply change all of my made up tags to paragraphs with ID's.

    I actually take issue with his suggestion of how to do it properly.

    1. A

      tag is for paragraphs. I see people using it all the time instead of a div -- simply for spacing purposes or because it seems gentler. If it's not a paragraph, don't use it.

    2. You don't need or want to stick ID's on everything unless you need to target it specifically (e.g. with Javascript). Use classes or just a straight-up div.

提交回复
热议问题