What's the
tag for?

前端 未结 3 390
走了就别回头了
走了就别回头了 2021-02-03 18:04

Is there any logical reason for using the

,
and
tags instead of nested, CSS-styled
    and
      tags? Or are they just an outdated g
相关标签:
3条回答
  • 2021-02-03 18:22

    From the W3C documentation:

    Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content.

    There are a couple of markup examples on the W3C page.

    0 讨论(0)
  • 2021-02-03 18:27

    Citing the W3C spec:

    The dl element represents an association list consisting of zero or more name-value groups (a description list). Each group must consist of one or more names (dt elements) followed by one or more values (dd elements). Within a single dl element, there should not be more than one dt element for each name.

    So the main reason for the <dl>, <dt> and <dd> tags are to preserve the semantic connection for those name-value pairs, which would get lost, if you just used nested lists.

    If you use nested lists, this could be done for various reasons (currently, e.g., many menus are structured into nested lists) and crawlers or any other system, that respects semantic annotations, would not be able to tell the difference.

    If you use the above tags, however, a system can see the connection and act accordingly. So a future use maybe to extract all definitions of terms inside a larger document to create some kind of glossary.

    0 讨论(0)
  • 2021-02-03 18:28
    DL
    A definition list is the container element for DT and DD elements. The DL element should be used when you want incorporate a definition of a term in your document, it is often used in glossaries to define many terms, it is also used in “normal” documents when the author wishes to explain a term in a more detail (Like this definition).

    DT
    The term currently being defined in the definition list. This element contains inline data.

    DD
    The definition description element contains data that describes a definition term. This data may be either inline, or it may be block level.

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