Is it fine to use span elements in div elements?

前端 未结 2 369
臣服心动
臣服心动 2020-12-22 13:36

I am making a website with personal articles. The body of my articles is a basic div containing paragraphs, but recently I found it useful to use some spa

2条回答
  •  青春惊慌失措
    2020-12-22 13:36

    It’s fine if no other text-level element is appropriate in your case.

    You can check their purposes in the usage summary: Does it represent a hyperlink, stress emphasis, importance, a side comment, …? If the answer is no to all candidates, go with "Other", i.e., the span element.

    div and span elements don’t represent anything, they are meaningless elements to be used in cases where no other element is appropriate. So adding/removing div/span elements would never change the semantics of the document (unless meaningful attributes, like lang, were used).

提交回复
热议问题