Reply to Re: What's wrong with this HTML (fails validation) ?

Your name:

Reply:


Posted by John Hosking on 02/16/07 04:53

robert maas, see http://tinyurl.com/uh3t wrote:
>>From: John Hosking <J...@DELETE.Hosking.name.INVALID>
>>http://www.w3.org/TR/html401/struct/text.html#h-9.3.2
>
> Start tag: required, End tag: forbidden
>
> It doesn't say anything about empty tag. Allowed or forbidden??

Required. You have to read the whole section. Here's some possible help
with making out the DTD bits:
http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.3

The "EMPTY" keyword means that this type must not have content.
So it's <br> in HTML 4.01. You may add certain attributes, but the
element starts with a tag beginning with "<br" and ending with ">" has
no content, and has no closing tag.
>
> 9.3.4 Preformatted text: The PRE element
>
> it doesn't say how to suppress the blank line at the end of each PRE element.

That's not the standard's job. Anyway, the choice of adding space after
an element or not is the browser's, not the W3C's.

> Also this entire section doesn't say which doctype it's applicable to.
> For example, is it applicable to "transitional" or not?

Yes. It applies to both strict and loose.

> Actually it looks like you have provided no links to HTML/XHTML
> transitional at all.

Sorry. I guess I'm done transitioning. But then again, *I* never
attended De Anza College. ;-)



>>XHTML Appendix C: <br /> and <hr />
>>http://www.w3.org/TR/xhtml1/#C_2
>
> Include a space before the trailing / and > of empty elements, e.g.
> <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the
> minimized tag syntax for empty elements, e.g. <br />, as the
> alternative syntax <br></br> allowed by XML gives uncertain results in
> many existing user agents.
>
> Well, per that, I was doing exactly the right thing!!
> Why are you all complaining???

Well, the thing is, nobody much likes Appendix C. I think that's because
it relies on browser weaknesses (and then *formalizes* it by adding it
to the W3C docs). For strict conformance, it's best to stay away from
Appendix C, which means not trying to serve XHTML to IE, which means
staying with HTML 4.01. And strictly speaking, <br /> is not valid HTML.

I mentioned Appendix C because it exists, and provides a weasel-way out
in certain circumstances. I don't like it, want it, trust it it or fully
understand the implications of it, but it *is*.

Anyway, I thought you were trying to do _HTML_ transitional everywhere.


> Hmm, I've started doing <p></p> instead, i.e. no space between the
> opening and closing paragraph delimiters. Is that wrong??

Don't know. Anyone else?
I *do* know an empty paragraph is a pretty weird thing. I've never had a
need for one on any of my pages, at least not since I learned to acheive
vertical spacing in other ways than extraneous <p> and <br> elements.

> She wanted all our *new* documents to be transitional, so they'd
> still "work" in existing Web browsers, yet they'd already work in
> future XML-based Web browsers.

In 2004, that's silly.

> It had nothing to do with any legacy
> documents. If you look at the class assignments (URL earlier
> above), one very early assignment was to make a template which
> would then be copied as the starting point for all future
> assignments which would all be brand-new from-scratch (well
> from-template) pages. Please take a look at that template and tell
> me if there's anything wrong with using it for brand-new documents.

Here's one from Beauregard T. Shagnasty you might prefer:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>My Template</title>
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="language" content="english">
<meta http-equiv="dialect" content="us">
<meta http-equiv="window-target" content="_top">
<meta name="author" content="<Your name>">
<meta name="description" content="<Your description">
<style type="text/css" media="screen">@import "yourcssfile.css";
</style>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>

<body>
<div id="logo">
[Insert your logo code here]
</div>

<div id="content"><!-- Content section -->
[Each individual page's content goes here]
</div> <!-- End of Content -->

<div id="nav"> <!-- Begin menu -->
[Your menu code goes here]
</div> <!-- End menu -->

<div id="footer">
<p>Copyright &copy;2007 Your Name Here. All rights reserved.</p>
</div>
</body>
</html>

Now save it as "template.html" (remember to change the <your name>
stuff). I'm not sure about the "window-target" meta tag so find out
before you use it; maybe you can leave it out. Otherwise I didn't change
his template much.


>>but there *was* a time when specifying a transitional doctype was
>>good advice (or at least, widely recommended; Jukka or BTS or
>>somebody will have the details).
>
> When was that?

Oh, late 1990s?


> Well if you think you can find a way to use a br or hr without
> violating one of these rules:
> Start tag: required, End tag: forbidden
> INCORRECT: unterminated empty elements <br><hr>
> Feel free to tell how to use BR or HR in HTML/XHTML transitional documents.

No, I'll tell you to use <br> and <hr> in HTML 4.01 Strict.

If you _must_ use XHTML, use <br /> and <hr /> if you're targeting IE6
(you said you weren't, really), because IE6 doesn't handle real XHTML
served as XHTML (this is the Appendix C fudge).

If you need to use XHTML and can serve it as XHTML to XHTML-capable
browsers, then use <br/> and <hr/> or <hr></hr>.

Enough for me for now; must sleep. At least I've found somebody even
more verbose than myself. ;-) Can't wait to see what Toby comes up with
for your totals next Sunday.

--
John

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация