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
?
The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!
The <div> tag is an empty container that is used to define a division or a section. It does not affect the content or layout and is used to group HTML elements to be styled with CSS or manipulated with scripts.
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 theclass
,lang
, andtitle
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 thediv
element leads to better accessibility for readers and easier maintainability for authors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With