HTML中DIV元素的有效属性是什么? [英] What are valid attributes for the DIV element in HTML?

查看:1312
本文介绍了HTML中DIV元素的有效属性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是有效的 DIV 属性?



基于这个链接,它只显示 class id title 。那是对的吗?意思是属性的对于 DIV

解决方案

请参阅 W3C规范



  • id class (文档范围的标识符)
  • lang 信息), dir (文字方向)

  • title

  • style (内联样式信息) code>(alignment)
  • onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup


for 用于 label ,并指定属性的输入元素,标签适用。

另见 HTML5 specs


$ b


div 元素根本没有特别的意义。它代表了它的孩子。它可以用于 lang title 属性来标记一组连续元素的通用语义。


注意:强烈建议作者查看 div 元素作为最后一招的元素,因为当没有其他元素适合时。使用更合适的元素而不是 div 元素可以提高读者的可访问性,并且更易于作者维护。




What are all the valid DIV attributes?

Based on this link, it appears only class, id, title. Is that correct? Meaning, the for attribute and others is not valid for DIV?

解决方案

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.

这篇关于HTML中DIV元素的有效属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆