You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I assume the reason you would want empty elements (i.e. <input>, <br>) to be "self closing" (e.g. <input />, <br />) is so that an XML parser would parse the HTML source as a well-formed XML document.
I can see the reason for dropping the value from boolean attributes, because it saves bytes, but if that is the reason, then you should also drop the self-closing declaration.
In other words it seems consistent to use either boolean attribute values with self-closing declarations or drop them both:
<input type="checkbox" selected="selected" />
OR
<input type="checkbox" selected>
NOT
<input type="checkbox" selected />
With that said, I'm open to learning the reasoning behind the guidance.
The text was updated successfully, but these errors were encountered:
I don't think there's a technical reason to self-close void tags if the doctype isn't xhtml. This standard is in place not to save bytes, but for readability and consistency amongst developers who are writing html.
The guidance for HTML closing tags and boolean attributes seems to be contradictory.
I'm referring to this text:
From https://github.com/thenerdery/html-css-standards/blob/master/standards/html.md#closing-tags:
From https://github.com/thenerdery/html-css-standards/blob/master/standards/html.md#boolean-attributes:
I assume the reason you would want empty elements (i.e.
<input>
,<br>
) to be "self closing" (e.g.<input />
,<br />
) is so that an XML parser would parse the HTML source as a well-formed XML document.However, if boolean attributes "should not have a value," then an XML parser would not consider the document well-formed. See https://stackoverflow.com/questions/6926442/is-an-xml-attribute-without-a-value-valid.
I can see the reason for dropping the value from boolean attributes, because it saves bytes, but if that is the reason, then you should also drop the self-closing declaration.
In other words it seems consistent to use either boolean attribute values with self-closing declarations or drop them both:
<input type="checkbox" selected="selected" />
OR
<input type="checkbox" selected>
NOT
<input type="checkbox" selected />
With that said, I'm open to learning the reasoning behind the guidance.
The text was updated successfully, but these errors were encountered: