3 ms·
If you don't close your tags, <div>foo<a>bar<span>baz box how can you tell the difference between, <div>foo<a>bar</a><span>baz</span> box</div> and <div>fo
by seasoup 17y ago
If you don't close your tags,
<div>foo<a>bar<span>baz box
how can you tell the difference between,
<div>foo<a>bar</a><span>baz</span> box</div>
and
<div>foo<a>bar<span>baz</span> box</a></div>
- jws 17y agoThe HTML tag closing rules specify they only get closed when they have to be. So neither of your solutions is correct. It is: <div>foo<a>bar<span>baz box</span></a></div>
- adelevie 17y agomy solution was to merely demonstrate the difference between what a programmer writes and what gets sent as an http response.
- adelevie 17y agoRendered html that will be sent has an http response should have ending tags. That doesn't mean the programmer/designer has to write them: #a dumb ruby example: def p(content) "<p>"+content+"</p>" end p "hello" #=> "<p>hello</p>"
- nostrademons 17y agoBy "don't close your tags", I mean "don't close your tags when the HTML spec does not require you to." You still need to close your <a>, <div>, and <span> tags. You don't need to close your <li>, <th>, <tr>, <td>, <dl>, <dt>, and several other tags. You don't even need to open your <html> and <head> tags, if you're not doing funky stuff like putting comments in them.