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

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

How does a header look in X(HT)ML 5 ?

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

How does a header look in X(HT)ML 5 ?

Postby rogersan » Fri May 11, 2007 6:19 am

Good morning.
<!DOCTYPE html><html><head><meta charset="UTF-8" />......
is the right init for HTML5, as far as i know.

But what exactly looks the XHTML5 equivalent?
I tried with different combinations but the Conformance Checker (http://hsivonen.iki.fi/validator/html5/) does always fall back to text/html and thus to html5.
Last edited by rogersan on Sat May 12, 2007 12:53 pm, edited 3 times in total.
rogersan
<h6>
 
Posts: 4
Joined: Fri May 11, 2007 6:05 am

Postby zcorpan » Fri May 11, 2007 10:08 am

XHTML5 is XML, thus you need an XML MIME type. (Try a file extension of ".xml" or ".xht".)

Then it typically begins with
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

HTH,
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby rogersan » Fri May 11, 2007 2:59 pm

Ok, with .xml file extension it displays:

"Warning: text/* type without a charset parameter seen. Defaulting to US-ASCII per section 3.1 of RFC 3023.

Warning: External encoding information specified a non-UTF-8/non-UTF-16 encoding (US-ASCII), but there was no matching internal encoding declaration. The well-formedness status of this document may change when decoupled from the external encoding information."

Although using this header:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="content-type" content="application/xhtml+xml; charset=UTF-8" />

What's wrong with that?
rogersan
<h6>
 
Posts: 4
Joined: Fri May 11, 2007 6:05 am

Postby zcorpan » Fri May 11, 2007 5:08 pm

rogersan wrote:Ok, with .xml file extension it displays:

"Warning: text/* type without a charset parameter seen. Defaulting to US-ASCII per section 3.1 of RFC 3023.

Warning: External encoding information specified a non-UTF-8/non-UTF-16 encoding (US-ASCII), but there was no matching internal encoding declaration. The well-formedness status of this document may change when decoupled from the external encoding information."
Yeah, that's an unfortunate part of text/xml... you may want to configure the server to serve .xml files as application/xml instead (or use .xht or .xhtml file extension which should result in application/xhtml+xml). If you only use us-ascii characters though it doesn't matter.
rogersan wrote:Although using this header:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="content-type" content="application/xhtml+xml; charset=UTF-8" />

What's wrong with that?
Nothing wrong per se, although the doctype doesn't do anything, name="" looks like you intended http-equiv="", and <meta> is never an encoding declaration in XML. If you want to declare the encoding in the file for XML then use the XML declaration (although XML defaults to UTF-8 anyway).
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby rogersan » Fri May 11, 2007 9:55 pm

So this would be a conform header for xhtml?

<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=us-ascii" />

and this one would fit to the xhtml5 specs?

<?xml version="1.0" encoding="us-ascii"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="content-type" content="application/xhtml+xml; charset=us-ascii" />

Both, http-equiv="content-type" and name="content-type" work for me and validate as xhtml strict, whereas only name="content-type" validates as xhtml5 and http-equiv="content-type" causes an error message:
"Error: Bad value for attribute http-equiv."

I always get this "missing charset" warning (xhtml and xhtml5), but you're right, this is a server-side issue. Since I use only free webspace there's nothing I can do. But it's only a warning, not an error. In such case, it would be the best to use the us-ascii characters, I agree.

Btw .xht and .xhtml extensions causing
IO Error: Non-XML Content-Type: text/plain
rogersan
<h6>
 
Posts: 4
Joined: Fri May 11, 2007 6:05 am

Postby zcorpan » Fri May 11, 2007 10:33 pm

Why do you insist on including a <meta>? It does exactly nothing. But otherwise it looks ok. (You don't actually need the XML declaration either, since us-ascii is a strict subset of utf-8.)

.xht and .xhtml resulting in text/plain means that your server doesn't know about these file extensions.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby Cerbera » Sat May 12, 2007 4:02 am

As I understand it, these two XHTML samples would be functionally identical if the document only uses UTF-8 characters (which includes those present in US-ASCII):
Code: Select all
<?xml version="1.0" encoding="us-ascii"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="content-type" content="application/xhtml+xml; charset=us-ascii" />
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
The second sample is about one third of the size of the first.
Cerbera
<h4>
 
Posts: 34
Joined: Wed Feb 21, 2007 1:04 pm

Postby rogersan » Sat May 12, 2007 7:07 am

zcorpan wrote:Why do you insist on including a <meta>? It does exactly nothing.


It was this "charset" warning message making me confuse, sorry.

Found this, fitting the topic:
http://my.opera.com/community/forums/fi ... id=2031767
rogersan
<h6>
 
Posts: 4
Joined: Fri May 11, 2007 6:05 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest