winterheat — 2008-10-27T20:30:16-04:00 — #1
sometimes I don't add </tr> or </td> in table formatting, and most of the time it is no problem. (HTML 4.01 spec says both of them are optional).
But I remember in some situation, they gave some problem with the table formatting until i added the </td> and </tr> back and the problem went away.
could it be that because the page was in XHTML 1.0 instead and that mandates a closing tag? although, modern browsers should be smart enough to understand <td>1<td>2 and not mess up even when it is XHTML 1.0. Does someone know, if an actually browser will choke if </td> or </tr> is not used? thanks.
ryanreese — 2008-10-27T20:33:03-04:00 — #2
In XHTML it is required to end all tags where it is due. For more information read the stickied thread about XHTML. FF may be smart enough to know when to not choke, but what about IE? How would you fix that? Also your way wouldn't validate and it is poor coding practice to not end all tags properly:sick:
scallioxtx — 2008-10-27T20:33:23-04:00 — #3
In XHTML no closing tag is optional!
That also means <br> becomes <br/>, <hr> becomes <hr/> etc
Just like XML, all tags have to be closed
ryanreese — 2008-10-27T20:38:35-04:00 — #4
A good way to fix errors is by using W3's validation services. It is a great trip there because you get another site dissing your own . Oh and you can fix markup :D.
[ot]Is that better way to tell them?
Post 600! I'm a guru now :D. Paul move over.[/ot]
winterheat — 2008-10-27T20:56:12-04:00 — #5
you mean it "is" required? my main concern is, where can it actually mess up a modern browser? i remember seeing it happen before, but usually i work with HTML but not XHTML.
ryanreese — 2008-10-27T20:57:34-04:00 — #6
I had it as "is" but my post got edited by a certain someone (BBoardx..)
Yes it can mess up a browser. It is required to conform to the rules.
felgall — 2008-10-27T21:02:38-04:00 — #7
Any missing close tags in XHTML will stop most browsers from being able to display the page at all. The only browser that doesn't care about whether you close your tags in XHTML or not is Internet Explorer because it only offers the file for download as it cannot display XHTML at all.
ryanreese — 2008-10-27T21:23:10-04:00 — #8
I am reading the FAQ's on HTML since I have W3schools certification tomorrow (hope I pass).
IE just plain doesn't support XHTML. They won't display it: they have no idea what the f*ck it is.
karpie — 2008-10-27T23:18:42-04:00 — #9
OK I had to go look it up now, I'd never heard of such a certification... that's some sort of really bad joke, right? :/
cooper_semantics — 2008-10-28T00:22:11-04:00 — #10
winterheat — 2008-10-28T01:21:31-04:00 — #11
that's interesting... the exam doesn't say whether it is open book or not (like you can read any book or check on the internet provided that you finish the exam in 70 minutes). why i think it might be more relevant when it is open book? because when we work in real life, we actually can use any reference book or look up any info on the internet.
by the way, Boltz already became a "Sitepoint Guru" by posting more than 600 posts... hm... it sounds better than Sitepoint Mentor or Sitepoint Advisor, just that there is no badge... only if he can use CSS to overlay a badge under his name using negative margins or position: relative.
autisticcuckoo — 2008-10-28T02:54:51-04:00 — #12
If the page displayed at all without those end tags, you weren't using XHTML. My guess is that you were using pretend-XHTML (XHTML markup served as
text/html). That is just HTML with syntax errors in it, it's not XHTML.
No, they shouldn't. In fact, they mustn't. The XML specification mandates that an XML parser abort as soon as it encounters a well-formedness error. And since XHTML is an application of XML, a compliant parser must stop if a
</tr> tag is missing.
You can also write
<hr></hr>, although that may cause problems if you use pretend-XHTML.
That's because XHTML is an application of XML.
winterheat — 2008-10-28T03:06:18-04:00 — #13
I see. thanks. so if i am for sure using HTML 4.01, then no need to serve the </td> and </tr> closing tags...
if using XHTML 1.0, then must use </td> and </tr>...
i think i saw a doc saying when a tag is empty, then no need closing tag, but that means it is one of those <br> or <hr> where you can either close it by </br> or </hr> or you still have to close it by <br /> and <hr /> huh? in other words, you always have to close it, just that for those, you don't have to use a closing tag but use a self-closing one.
i wonder if i am serving a large table of numeric data, such as ... 1.2MB, and let's say each row has 8 cells, then how much faster it is if the doc has no </td> and </tr> versus if there are, assuming the data is passed using "gzip, deflate" and the transfer rate is 300kb/s. will do some experiment later... right now... working on a project using greasemonkey...
autisticcuckoo — 2008-10-28T03:45:53-04:00 — #14
Not syntactically, no. But those end tags tend to make the markup much more easy to read for human beings.
Yes, there must be a matching end tag for every start tag in X(HT)ML.
The element types declared as
EMPTY in the HTML DTDs must not have an end tag. There are no
</meta> tags etc in HTML.
For element types that can have content, the end tag is required even if the element is empty (except for those element types that have an optional end tag).
In XHTML it's different, since it must be well-formed. Even empty elements need a closing tag. Instead of
<br></br> etc XML offers a shorter notation,
<br/>. It's called a null end tag (NET), and it's a feature that is theoretically available even in HTML (albeit with a different syntax), but no browsers support it in HTML.
<br/> in HTML actually means something different than in XHTML (it means
<br>>). But all browsers have buggy parsers that interpret it as
<br>, which is why pretend-XHTML works.
In real XHTML you can use NET syntax for any empty element, even if it's not declared as
EMPTY. For instance, the following is perfectly valid XHTML:
You can't use this in pretend-XHTML, though. NET syntax can only be used with
EMPTY elements in pretend-XHTML.
In HTML you just use
<hr>. In XHTML you'd normally use
<hr/>. In real XHTML you could also use
<hr></hr>, but there's no reason to. In pretend-XHTML it's customary to leave a space before the NESTC delimiter (
<br /> etc) to cater for extra-buggy HTML parsers.
stomme_poes — 2008-10-28T05:33:52-04:00 — #15
Here is an example of someone really putting HTML4's "optional" tags to the test. This page is actually valid, though (deliberately) sloppy.
It would not be as XHTML but he's smart enough to know that XHTML gives no benefits if served the way he's serving it so he stayed with HTML4.
winterheat — 2008-10-28T06:13:20-04:00 — #16
no <head>, no <body>, no </li>, yet it is valid 4.01 strict code. He is my new hero. (just kidding).
c_ankerstjerne — 2008-10-28T07:23:30-04:00 — #17
I wouldn't call it sloppy. Impractical and perhaps a bit provocative, yes, but not sloppy.
stomme_poes — 2008-10-28T07:40:36-04:00 — #18
Hmmm, okay, not sloppy, but definitely provocative : ) He told me "don't believe everything they tell you" and maybe wants his site to be as lean as possible.
I styled the page originally and rewrote the HTML from what is was originally, but he removed my "looks nice at 600x800" setup and then removed all the "superfluous" tags lawlz. So I didn't want my name on the page.
spacephoenix — 2008-10-28T14:28:22-04:00 — #19
When using FF Ctrl+A will upload the current page to the W3's validation service.
winterheat — 2008-10-28T16:47:22-04:00 — #20
also, if you install Wed Developer's Tool on FF, at the top right corner of the window at the toolbar, you will see the checkmark for HTML and CSS as well.
PS. I just found that a green checkmark for HTML doesn't mean anything... it merely indicates it is Compliance mode but doesn't validate the HTML. The CSS checkmark does say there is no CSS error... but supposedly the w3c.org one is more authoritative.
next page →