You are not logged in.
http://w3schools.com/html5/tag_hr.asp
It's about HTML5, they use <hr /> in an example but <hr> below the example. So it's uncertainty for those who tend to follow standards. When it's about HTML5 as it is - which way is more correct - to always use closing tag or not to use it in tags such as <hr> and <br>?
Last edited by Mr. Alex (2011-09-18 17:09:20)
Offline
You mean
The <hr> tag creates a horizontal line in an HTML page.
- I think it's just the way they call tags.
Edit: Ah, no, the page code shows
<p>The <hr> tag is supported in all major browsers.</p>
<hr>
<h2>Definition and Usage</h2>Edit2: Hmm, I get the above piece of code when using 'View selection source' from Firefox' context menu, but when viewing the whole page source, it shows
<p>The <hr> tag is supported in all major browsers.</p>
<hr />
<h2>Definition and Usage</h2>Edit3: http://www.html-5.com/tags/hr-tag/index.html
Since the <hr/> tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiters /> rather than just > (<hr/>).
Last edited by karol (2011-09-18 13:31:53)
Offline
The / is optional, see:
http://dev.w3.org/html5/markup/syntax.html#void-element
This silver ladybug at line 28...
Offline
lolilolicon, yeah, it says pretty definitely:
Void elements only have a start tag; end tags must not be specified for void elements.
...
A non-void element must have an end tag...
karol, thanks but link you posted seems not to be official site whereas dev.w3.org is official. So I guess we don't need to close <hr>, <br> and other void tags.
Offline
Mr. Alex, I think you might have misunderstood it -- <hr/> is a start tag:
start tags consist of the following parts, in exactly the following order:
A "<" character.
The element’s tag name.
Optionally, one or more attributes, each of which must be preceded by one or more space characters.
Optionally, one or more space characters.
Optionally, a "/" character, which may be present only if the element is a void element.
A ">" character.
so in HTML5, each one of <hr>, <hr >, <hr/> and <hr /> is correct.
(...also there's the "unless..." part following "A non-void element must have an end tag".)
Last edited by lolilolicon (2011-09-18 15:34:01)
This silver ladybug at line 28...
Offline
OK, thanks.
Offline
I forgot to post that http://w3schools.com/html5/tag_hr.asp is xhtml and not html5 so looking at the code of that page is irrelevant to the issue in question.
Should have checked this in the first place.
I now agree with lolilolicon that at least atm the '/' in <hr/> (and in other void elements) is optional. Furthermore, searching the current drafts, specs and recommendations I could only find <hr> in every example :-)
Adding '/' may have some benefits or it may be good practice, but it's not obligatory.
If your questions has been answered, please mark this thread as solved.
Offline