difference between div and span tag

前端 未结 10 1494
眼角桃花
眼角桃花 2020-12-29 04:33

Can anyone give me the difference between div and span tags?

10条回答
  •  感情败类
    2020-12-29 04:38

    In HTML, both and

    (division) are structural elements of a document. Both can have nested tags, attributes applied, and can be used to provide styling, semantic clarity and access from dynamic code or when navigating the Domain Object Model (DOM). They're difference lies in their coverage. A maintains coverage in-line, whereas a
    is block-level. Their versatility, and perhaps previous lack of alternatives, leads these popular tags to overuse.

    Now HTML5 has specific tags that should be used in place of and

    , including
    (forms), , , ,
    ,
    , and
    , just to name a few. These new additions should be used in more specific scenarios they were designed for.

    For more information, look at Section 4, "The elements of HTML", from W3C. In particular, look for the sections, grouping contexts and forms.

提交回复
热议问题