

Ask HN: What's wrong with the HTML in this line? - brandnewlow

A friend of mine had to take a test for a job as a TV presenter that, strangely, had some HTML questions on it.  I guess the station has decided that everyone needs to know something about the web.<p>Anyway, one of them was "what's wrong with the HTML in this line:"<p>&#60;p&#62;(&#60;a href="http://www.amazon.com/Flip-MinoHD-Camcorder-Minutes-Black/dp/B001HSOFI2" target="_blank"&#62;Amazon.com&#60;/a&#62;)&#60;/p&#62;<p>As far as I can tell, there is NOTHING wrong with that line.  But am I missing something obvious?
======
mooism2
They may be objecting to use of target, which isn't allowed in html 4 strict
as far as I remember. But if they're expecting TV presenters to hand-write
html, that's a bit picky.

------
RiderOfGiraffes
I regard this as a chance to learn something about the technical details of
HTML, so my answer whould not be regarded as definitive. Or even correct.

However ...

It depends on the variant of HTML, but surely "<p>" is not a, what's the
technical term, container? In the variants of HTML that use <p> you don't then
have to have a </p> because it's not of the open/close variety.

~~~
mooism2
"Block element"? Yes it is. The "</p>" is optional, not banned.

~~~
RiderOfGiraffes
OK, thanks. In what variants? And is it regarded as "Good Style" (whatever
that might mean)

~~~
mcav
In XHTML, the </p> is required. In HTML, some people prefer to close all tags
for cleanliness; others prefer to leave the <p> open. It's really a personal
preference. Personally, I like the more minimal approach of leaving the
closing tag out (one less thing to try to match up). Others like it to look
like XML (everything closed).

As far as the original post's question -- that HTML snippet is perfectly fine.

~~~
TeHCrAzY
I find unclosed tags to be ambiguous, hard to format, and that they lead to
more errors, I'd be interested to see why you prefer working with the
opposite, personal preference aside.

~~~
mcav
I don't leave _every_ tag open; just a few: tr, td, p, li.

To me, it's intuitive that when the next row/listitem/paragraph begins, the
first one ends. So I think this is perfectly readable:

    
    
      <ul>
        <li>Item1
        <li>Item2
        <li>Item3
      </ul>
    
      <table>
        <tr>
            <td>Foo
            <td>Bar
            <td>Baz
       
        <tr>
            <td>Foo
            <td>Bar
            <td>Baz
      </table>

------
maxdemarzi
Maybe it's not a technical question, but a logical question.

It's a direct to product link labeled as a company link?

