These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:25 pm Advanced search

Conforming HTML 5 document

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Conforming HTML 5 document

Postby Ritz » Wed Mar 11, 2009 4:16 pm

Is it wrong, or is there the possible risk that it will be wrong (non-conforming) in the future, to use self-closing element tags like <br /> or ending tags like </p> in a plain HTML 5 document?

For example, from my XHTML 1 coding habits, all my basic documents look like very similar this:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>This is an HTML document</title>
</head>
<body>
<p>Some<br /> text</p>
</body></html>

I do this because I put my code through an XML editor to catch when myself when I miss an </a> tag for example. I know you can get away with not using those tags and still conform to the spec. But it's my preference right now to close everything.

What's the consensus?
User avatar
Ritz
<h6>
 
Posts: 6
Joined: Wed Mar 11, 2009 3:53 pm
Location: Calgary, Alberta, Canada

Postby mskinner » Wed Mar 11, 2009 10:02 pm

I recommend that you use XHTML5 if you want to perform XML validation
...remember XHTML is HTML formulated as an XML document :-)

Browsers can be pretty forgiving of closing elements (even with HTML4 vs XHTML 1.x) - most browsers will want to support closing elements anyway (if they don't already).
mskinner
<h2>
 
Posts: 116
Joined: Sun Jun 24, 2007 12:20 am
Location: Melbourne, Australia

Postby lyosha » Wed Mar 11, 2009 10:11 pm

Your document is fine as both HTML and XHTML, the only thing that is kind of discouraged in the HTML serialization is self-cloding tags ending in /> even though they are fully valid (and I use them too in HTML for my own reasons). The rest will probably never become non-conforming.
lyosha
<h3>
 
Posts: 60
Joined: Fri Aug 22, 2008 9:26 pm

Postby Ritz » Wed Mar 11, 2009 11:07 pm

mskinner wrote:I recommend that you use XHTML5 if you want to perform XML validation ...remember XHTML is HTML formulated as an XML document :-)


Well, you see, I like the idea of well-formed code, but I do not like the idea of declaring it as XHTML as such.

I recently rebuilt a website for a social group using XHTML. I made sure every page validated as XHTML and then served it as text/html so that IE 6 could render it properly. Unfortunately, I was just put in charge of restructuring the site and would not and do not have any control over the content put into it after it's completion. And you know the editor they use to change the content now? Frontpage.

Here is an example of a page they haven't touched yet: http://www.ucalgary.ca/~sdc/about/const/
Here is an example of a page they have edited with Frontpage: http://www.ucalgary.ca/~sdc/announ/

Ugh! <font>! But it gets worse, still. Browsers still handle the second example as tag soup and agree to render the page. W3C's semantic extractor tool? Not so much. But that same tool will parse http://www.posthotel.com/posthotel/index.html just fine.

Anyway, the point is, I'm a standards aware developer that observes the fact that HTML tag soup is more accessible than invalid XHTML served as text/html. So while I wish my pages to conform to HTML standards using well-formed XHTML syntax, I am making a deliberate choice not to declare it as XHTML.

And I just wanted to make sure that was kosher.
User avatar
Ritz
<h6>
 
Posts: 6
Joined: Wed Mar 11, 2009 3:53 pm
Location: Calgary, Alberta, Canada

Postby lyosha » Thu Mar 12, 2009 7:45 pm

Yeah, it's just fine.
lyosha
<h3>
 
Posts: 60
Joined: Fri Aug 22, 2008 9:26 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests