Is the option tag a self-closing tag?
Start tag: required , End tag: optional
That is for HTML 4, so one can assume it is still the case with HTML5. However, when the stricter XML compliance rules apply, it may not be the case.
HTML can be served as
text/html or as
application-x/xml, the latter adhering to the stricter spec.
Going through the HTML5 docs I’m still looking for clarification…
Hi, no expert here, but, if you don’t use the closing tag
</option> here at codecademy the linter or whatever it is that puts a red dot on the code line number will show it’s not right. So most likely it’s not a self closing tag. Empty elements and void elements and self-closing are all three the same thing.
But it is when inside a
<datalist/>. Linters don’t tell us if markup is valid, just if it has some quality issues.
validator.w3.org is where to get the real low down on our markup.
You are evidently much more knowledgeable about this area of computer technology than i am ok. But, I am not convinced
<option>is a void or self closing tag just because in a few cases you don’t need the closing tag Link to the HTML5 specification of this tag. Maybe i am being a little too specific or narrow on this, but, a void or self closing tag like
<br>and <img> never needs a closing tag and I think of them as a true void or self closing tag. Whereas
<option> just acts like a void or self closing tag with regard to whether or not you or I need to put the closing tag in under specific circumstances. I would like to thank you for your answer as it has really helped me in sharpening my critical thinking skills with respect to learning the HTML5 computer language. I agree with you whole heartedly about W3C people being the ultimate authoritative source to go to though. They seem to be in charge of the actual development and evolution of the language itself to the best of my understanding.
For me the question is “why”. Why is it not a self-closing tag?
This page seems to have the answer: MDN option tag specs
Tag omission The start tag is mandatory. The end tag is optional if this element is immediately followed by another
<option>element or an
<optgroup>, or if the parent element has no more content.
I actually checked it and it worked. It is both a self closing tag and a normal tag. I’m not aware of the Standard form tho.
The different usage depends on whether it is a datalist (options are void elements) or a select element (options have a text node).
How is it used for a datalist and a select element respectively? I mean which one uses the option as self closing or a normal tag?
As stated, for datalist there is no text node,