SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 26
-
Nov 20, 2008, 10:09 #1
- Join Date
- Feb 2006
- Location
- Altoona, PA. USA
- Posts
- 1,945
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
should you put a space before your self inclosed tags?
For instance should it be <hr/> or <hr /> or does it not matter at all, or is there a general practice? I tend to like to add the space myself.
-
Nov 20, 2008, 10:12 #2
- Join Date
- Dec 2003
- Location
- USA
- Posts
- 2,582
- Mentioned
- 29 Post(s)
- Tagged
- 0 Thread(s)
It doesn't have to have a space, as a rule, but I also like to add the space before the />.
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
-
Nov 20, 2008, 10:14 #3
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You should:
Originally Posted by http://www.w3.org/TR/xhtml1/#C_2
-
Nov 20, 2008, 10:17 #4
- Join Date
- Feb 2006
- Location
- Altoona, PA. USA
- Posts
- 1,945
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Nov 20, 2008, 10:19 #5
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah. Unless of course you wish to set the content-type to application/xhtml+xml.
-
Nov 20, 2008, 10:26 #6
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- Posts
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
Correct. <br/> is semantically XHTML correct, but HTML parsers won't understand it. Using <br /> is the best practice when you're dealing with browsers that don't understand XHTML. I'm looking at you, IE!.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
-
Nov 20, 2008, 10:29 #7
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Which leads us to the fact that you might as well just use HTML instead of XHTML because you'll serve it as such and it will be parsed as such.
-
Nov 20, 2008, 10:37 #8
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- Posts
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
That is unfortunately the case. Because Microsoft refuse to support XHTML, they have effectively killed it.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
-
Nov 20, 2008, 11:04 #9
- Join Date
- Nov 2008
- Posts
- 65
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can find the WC3 recommendation for XHTML 1.0 at w3.org/TR/xhtml1/
See section 4.6. if you're serving your document as XHTML or C.2. if you're serving it as HTML.
-
Nov 20, 2008, 12:28 #10
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Basocally if you are using real XHTML then it is <hr/> and if you are not it is <hr>. The space before the slash just allows HTML to discard the invalid slash which may as well not be there in the first place.
Let's hope IE dies soon so that we can start serving our web pages properly as XHTML.Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Nov 20, 2008, 13:53 #11
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- Posts
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
Hear hear!
I'll get the pitchforks while you arrange the tar. I know of someone who's got the feathers.Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
-
Nov 20, 2008, 14:02 #12
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You still have the problem with the error handling when parsing XHTML. The slightest syntactical error will result in an ugly and confusing error message for the user.
-
Nov 20, 2008, 14:09 #13
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, but that's the whole point! X(HT)ML must be well-formed which makes it much easier to write an XML parser than an HTML parser (although there are other factors as well).
If you cannot guarantee well-formed output you definitely shouldn't even consider using an XHTML doctype declaration – even if you intend to serve it as text/html.
To me, a space before the NESTC+NET delimiters indicates someone who doesn't really know what he or she is doing. But that's just me.Birnam wood is come to Dunsinane
-
Nov 20, 2008, 14:12 #14
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Well formed (X)HTML is definitely far easier to maintain and saves loads of time that would be otherwise lost trying to trace errors caused by the browser deciding that the missing tag (that may be optional in HTML) belongs in a different spot to where you think it ought to be.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Nov 20, 2008, 14:32 #15
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
http://validator.w3.org/check?uri=ht...p%3Ft%3D584341
And yeah, I know that you are using vBulletin, but the layout is custom so it could've been made using HTML instead of XHTML. Just saying...
-
Nov 20, 2008, 19:50 #16
- Join Date
- Dec 2003
- Location
- USA
- Posts
- 2,582
- Mentioned
- 29 Post(s)
- Tagged
- 0 Thread(s)
We all know that the Sitepoint forum doesn't validate.
I wasn't aware that putting a space was actually not allowed. I guess since I've only seen it in books as " />" (since they were teaching it wrong) I never really thought about it.
I used HTML 4.01 Strict at the moment anyways, since we still can't use real XHTML reliably.Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
-
Nov 20, 2008, 23:30 #17
LOL, Tommy, and I thought this topic made me grumpy. It may not be so much that someone doesn't know what they're doing, but trying to do "the right (or modern) thing" and code in XHTML, and ending up making fundamental compromises such as this thread addresses. You're right, it makes more sense to code in HTML 4.01 Strict and let XHTML hang until the community/industry gets it correlated, but a tremendous amount of "expert" sites push the assumption that only XHTML coding is up-to-date. I know I spent some time trying to teach myself XHTML before learning (in these forums) that I was better off sticking with HTML Strict.
Off Topic:
just tweakin' you, buddy. Mrs. Max says hi.
Off Topic:
And how come Eric Meyer's site is in HTML Transitional? Like I'm the one to point fingers at him....
-
Nov 21, 2008, 00:05 #18
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Appendix C of the XHTML standard on making your XHTML compatible to be served as HTML actually specifies that the space is required in that situation. This is because the / is actually invalid when the page is served as HTML and the space is needed to stop it making the preceding attribute invalid as well. The space isn't needed when you are writing real XHTML for example <script type="text/javascript" src="myscript"/> (although adding the space wouldn't allow that XHTML to work as HTML either since in HTML it must have a separate closing tag for scripts).
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Nov 21, 2008, 00:55 #19
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
FYI, I, personally, have nothing to do with SitePoint Pty Ltd or the forum software. I'm just a volunteer moderator, which is like any other member but with a few extra privileges.
It is allowed. It's just not necessary.
What I meant was that most people who use pretend-XHTML (XHTML markup served as HTML) don't understand the real difference between XHTML and HTML. As you say, they've been duped into believing that pretend-XHTML is somehow better (more strict, more semantic) than HTML, which is, of course, ********.
In most cases it doesn't make much sense to serve X(HT)ML to clients at all, even if Microsoft should eventually decide to implement support for XHTML.
Every source on the Internet should be regarded with a healthy amount of scepticism and distrust. (Yes, that includes my blog, too.) The Web lets anyone publish anything.
You'll have to ask him about that. My guess is that he uses a publishing tool that doesn't guarantee pure markup, but it's just a guess.
Appendix C contains HTML compatibility guidelines; it's not a specification. The whole appendix is informative, not normative. So it can't state that something is required, only recommended.
No, it's not invalid. It just means something different than in XHTML. (Or, rather, it means the same thing, but uses a different syntax.) Virtually no HTML browser supports the SGML SHORTTAG feature which is declared for HTML (but not for X(HT)ML), so NETs are never used in honest HTML.
It doesn't make any attribute invalid. The space is recommended in pretend-XHTML because of some particularly buggy HTML parsers in antique browsers.Birnam wood is come to Dunsinane
-
Nov 21, 2008, 01:30 #20
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
That's basically the same thing as being invalid without the space. HTML parsers as you say don't accept the shorttag option and so wouldn't be expecting to see a / there. Netscape 4 (to name one of those "buggy" antique browsers) would then treat the slash as part of the preceding attribute (since without the space there is nothing to say that it isn't) and then that attribute would probably fail to work because of its ending with a slash.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Nov 21, 2008, 07:14 #21
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Nov 21, 2008, 08:45 #22
- Join Date
- May 2006
- Location
- Denmark
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
@AutisticCuckoo: I'm aware you aren't employed by SitePoint. I just chose that particular page to show that this entire forum would be entirely unusable, and thus this discussion wouldn't even take place, if it weren't for the fact that it was incorrectly served as "pretend-XHTML", i.e. (malformed) XHTML served as text/html.
-
Nov 21, 2008, 13:42 #23
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Nov 21, 2008, 13:55 #24
- Join Date
- Dec 2003
- Location
- USA
- Posts
- 2,582
- Mentioned
- 29 Post(s)
- Tagged
- 0 Thread(s)
It's buggy when compared with current standards. Back when Netscape 4 came out I don't think XHTML existed.
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
-
Nov 22, 2008, 01:33 #25
- Join Date
- Feb 2006
- Location
- East Moline, Illinois
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I read somewhere that it is a good idea to add the space because some browsers were in-compatible without the space. But I have no idea if it is true.
Master Newbie!http://dwight.byethost31.com/
Bookmarks