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

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

XHTML5 Skeleton Document

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

XHTML5 Skeleton Document

Postby wswartzendruber » Sat Jun 26, 2010 12:30 am

Can someone provide a skeleton XHTML5 document? I keep reading about required MIME declaration, but not all XHTML5 examples have this. I am rather confused.
wswartzendruber
<h6>
 
Posts: 4
Joined: Sat Jun 26, 2010 12:26 am
Location: California, USA

Postby JAB Creations » Sat Jun 26, 2010 12:57 am

You'll need the XML declaration, the not-a-doctype doctype, and generally the basic required elements such as head, body, title etc.

Without serverside content negotiation you can force the application/xhtml+xml mime/media type by setting the file extension to xhtml instead of html however keep in mind the Internet Explorer 8.0 and older are incapable of handling XHTML hence it's necessary to do content negotiation at the server to determine which mime/media type to serve.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby wswartzendruber » Sat Jun 26, 2010 1:08 am

Wait, so I need the DOCTYPE in there?
wswartzendruber
<h6>
 
Posts: 4
Joined: Sat Jun 26, 2010 12:26 am
Location: California, USA

Postby wswartzendruber » Sat Jun 26, 2010 1:10 am

How is this?

Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title></title>
   </head>
   <body>
   </body>
</html>
wswartzendruber
<h6>
 
Posts: 4
Joined: Sat Jun 26, 2010 12:26 am
Location: California, USA

Postby JAB Creations » Sat Jun 26, 2010 1:20 am

Using the W3C HTML validator this seems to validate...

*edit* I'm not sure about the XHTML namespace is compatible with HTML5 or what I would imagine offhand would be an XHTML5 application.

Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
</head>

<body>

<div>
<p>Example.</p>
</div>

</body>
</html>
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby JAB Creations » Sat Jun 26, 2010 1:23 am

For clarification doctypes are still included because of the standard and quirks modes browsers render documents or applications as.

Code: Select all
<a href="javascript:var m=(document.compatMode == 'CSS1Compat') ? 'Standards' : 'Quirks'; window.alert(m+'-mode.');">Detect Rendering Mode</a>
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby wswartzendruber » Sat Jun 26, 2010 1:39 am

Okay that makes sense. Here's (trimmed-down) what Wikipedia says is a valid XHTML5 document. One difference I see is that they added the language definition.

Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
      <title></title>
   </head>
   <body>
   </body>
</html>

Any comment on this?
wswartzendruber
<h6>
 
Posts: 4
Joined: Sat Jun 26, 2010 12:26 am
Location: California, USA

Postby JAB Creations » Sat Jun 26, 2010 2:59 am

I think that's part of WAI AAA compliance.

I use XHTML 1.1 for the application/xhtml+xml mime/media type which not only helps keep my productive though it's also XML so it's extensible. That means I can include (X)HTML5 features in XHTML 1.1 should I desire to do so. I don't agree with many things in HTML5 hence my decision to go that route. Also I try to ensure my applications are WAI AAA as best that I can which is generally difficult however it's influence on coding provides an inherent guide so-to-speak and like actual XHTML adhering to the standard requires you use good practices.

Here is an skeleton example of how I format my XHTML 1.1 applications...

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="language" content="EN" />
<meta name="robots" content="INDEX, FOLLOW" />
<base href="http://localhost/" />
<link href="themes/style.css?theme=classic" media="screen" rel="stylesheet" title="classic" type="text/css" />
<script src="scripts/index.js" type="text/javascript"></script>
<script src="scripts/onload.js" type="text/javascript"></script>
</head>

<body>

<div>
<p>XHTML 1.1 example.</p>
</div>

</body>
</html>
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: XHTML5 Skeleton Document

Postby zcorpan » Mon Jun 28, 2010 4:11 am

wswartzendruber wrote:Can someone provide a skeleton XHTML5 document?

Code: Select all
<html xmlns='http://www.w3.org/1999/xhtml'><head><title/></head><body/></html>

wswartzendruber wrote: I keep reading about required MIME declaration, but not all XHTML5 examples have this. I am rather confused.
The MIME declaration is in the HTTP Content-Type header. You can't see it in 'view source'. To set it, you need to configure the server to send your file as application/xhtml+xml, or just change the file extension to .xhtml and hope the server maps that to application/xhtml+xml. To inspect the HTTP headers, you can use http://www.rexswain.com/httpview.html or some browser extension or network inspector.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby zcorpan » Mon Jun 28, 2010 4:14 am

JAB Creations wrote:You'll need the XML declaration,
No.
JAB Creations wrote:the not-a-doctype doctype,
No.
JAB Creations wrote:and generally the basic required elements such as head, body, title etc.
Yes.

JAB Creations wrote:Without serverside content negotiation you can force the application/xhtml+xml mime/media type by setting the file extension to xhtml instead of html however keep in mind the Internet Explorer 8.0 and older are incapable of handling XHTML hence it's necessary to do content negotiation at the server to determine which mime/media type to serve.
Content negotiation is pretty pointless though. Plus, if an error slips through, you serve a working page to IE but an error message to XHTML-capable browsers.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby zcorpan » Mon Jun 28, 2010 4:16 am

JAB Creations wrote:For clarification doctypes are still included because of the standard and quirks modes browsers render documents or applications as.

Code: Select all
<a href="javascript:var m=(document.compatMode == 'CSS1Compat') ? 'Standards' : 'Quirks'; window.alert(m+'-mode.');">Detect Rendering Mode</a>
No. XML always gives standards mode. Try it with your script in an XHTML document without a doctype. :)
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby JAB Creations » Mon Jun 28, 2010 6:20 am

That's the strongest point of using XHTML over HTML, you are fully aware when there is an error and can in that very instant fix it right there on the spot. I've seen too many people spend hours finding out that they were missing a quote or something else as trivial.

...and it's yes for everything I mentioned for WAI AAA compliance.

Aim above the mark to hit the mark. :wink:
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests