<p> some paragraph </p>
<br></br>
<p> a second paragraph </p>
or: <p> some first paragraph </p>
<br><p> a second paragraph </p></br>
<p> a third thing </p>
Neither of those are valid, and the last one is interpreted as: <p> some first paragraph </p>
<br>
<p> a second paragraph </p>
<br>
<p> a third thing </p>
New users find behavior like this confusing all the time.The "/>" is syntax for a self-closing tag in xhtml (e.g. you were supposed to use <img src="" /> etc).
You see "<br />" a lot in php forums because these will often filter user input through the function nl2br whose purpose is to add HTML linebreaks wherever a person has a newline in their post. PHP's nl2br function by default inserts "<br />" unless you tell it specifically not to use xhtml-compatible linebreaks.
In fact they can be said to have no effect on parsing HTML itself, as the only time when self-closing makes any difference is when the tag's name isn't one that HTML defines - what the spec calls "foreign elements" (e.g. inline SVG or MathML). Those will close when their tag is self-closing, but the closing behaviour of HTML tags is hardcoded in the parser.
Sure. Interestingly </hr> is ignored, but <br></br> is parsed as a block of some kind. I did not know this, so yes, you can judge me for it.
I know you are poking me for what I said about self closing tags, but I stand by it. I've seen a lot of html, and it's one very easy way to find the bad programmers - they all self close <br>. I'm sure there are exceptions, but I have not come across any.
It's a sign of a tutorial programmer (not exactly), maybe, more or a copy/paste programmer, who finds "blocks" of code that work, and just apply it everywhere.
They tend to lack the deep fundamentals of how html works.
Anyway, I don't understand this discussion at all. I was expecting something a bit better from the HN community. Since when did we start making strong judgments based on purely esthetical things?
An applicant to a position we offered once submitted a code without <head/> nor <body/> tags, and his justification was totally right: the standard doesn't actually require it[1]. So does that make you a bad programmer for using them? Not using them? I believe nobody really care, and I would have to be a really bad person to judge my colleagues based on that.
[1] http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#opti...
I've been working with web technologies for years and I happened to like a lot of things about XHTML. I know how the shit works, I just feel its more consistent to close all of your tags. You obviously wouldn't self-close a <div> or a <section> because those tags are supposed to have content!
As an aside, I would argue that <script> should be nullable when it has a src attribute.
There are a lot of people, including me, who does it out of habit, aesthetic worries, or to make the markup easier to parse for (some) humans. It's a bit like using Egyptian Brackets in JavaScript.