What are valid attributes for the DIV element in HTML?

前端 未结 4 1184
悲哀的现实
悲哀的现实 2020-12-31 05:49

What are all the valid DIV attributes?

Based on this link, it appears only class, id, title. Is that correct? Mea

4条回答
  •  一向
    一向 (楼主)
    2020-12-31 06:25

    See W3C specs:

    • id, class (document-wide identifiers)
    • lang (language information), dir (text direction)
    • title (element title)
    • style (inline style information)
    • align (alignment)
    • onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

    for is for label and specifies the id attribute of the input element to which the label applies.

    See also the HTML5 specs:

    The div element has no special meaning at all. It represents its children. It can be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements.

    Note: Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. Use of more appropriate elements instead of the div element leads to better accessibility for readers and easier maintainability for authors.

提交回复
热议问题