Just purchased “Build your own Web site the right way…” and have been diligently learning the ropes? - The starting point for any web page, according to the book is:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-[COLOR=“Red”]strict[/COLOR].dtd”>
with the following meta tag appearing in the head section of the doc.
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”/
However when I was trying to copy over some pages from my iWeb site and noticed the opening text is as follows:
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-[COLOR=“SeaGreen”]transitional[/COLOR].dtd”>
I have highlighted the differences i.e. strict v’s transitional - my question is which is more correct??
Also - why in the iWeb site does the UTF-8 reference appear before the <!DOCTYPE>
Are these differences I should be concerned about or just ignore them??? i.e. both are correct or which is more correct??
Any advice would be appreciated.
Well my golden rule (for me that is) is that I start all new websites using HTML 4.01 Strict unless I’m using a CMS or blogging platform like WordPress, and even then I switch the doctype from XHTML Transitional to XHTML Strict. YMMV
I don’t know if I’d say if you aren’t you shouldn’t - maybe if you never will then you don’t need to.
But you have a point. If the pages don’t contain things like MathML or SVG and you’re certain they never will then HTML is fine.
You are right to a point mitt’s, but the main problem with what you have said is that in the circumstances mentioned, the XML declaration is outright wrong. As mentioned in the original post the MIME type being served is html/text, not application/xhtml+xml, thereby the document (even though it’s using XHTML) is actually in both cases being served as an HTML document (either in transitional or strict mode). Thereby, using the XML declaration where XML is not being used is technically and semantically invalid. The only case for using the XML DTD is for when you declare XHTML using the correct MIME type (which as you mentioned IE doesn’t support).
Robert already beat me to the <b> thing, and Alex has a good explanation of when you do use the XML declaration at the top (basically, if you’re building a typical web page, don’t use it).
Strict vs Transitional isn’t to do with HTML > XHTML, but old HTML to new HTML. There is a Strict and Transitional in HTML4 as well.
A good rule of thumb: if you’re building a new page, esp if you are learning how to do things the Right Way, stick to Strict. It means when you send your HTML to the w3c validator, it will point out (almost) all your mistakes, instead of only pointing out mismatched tags. Transitional will not point out any <center> tags.
WYSIWYGs like iWeb (never heard of it, an Apple product?), DreamWeaver, etc tend to start out in XHTML Transitional for some reason. I really don’t know why. The program is wrong. Lloyd’s book is correct (though he’s been on these forums and members have discussed whether newbies should be starting out with XHTML in the first place… nothing wrong with HTML4.01 Strict. Many of us prefer it : )
There is a case for using XHTML for it’s beneficial error reporting (as in a no BS policy when it comes to code), personally I love nothing more than the yellow screen of death reminding me that there’s something unsemantic hiding in the source code. Though you are entirely correct in that for the average user who doesn’t make use of XML content, they would be entirely better off sticking with traditional HTML as the benefits of using XHTML are likely to be limited (or nothing at all).
I see your question is being answered but may I add that as I understand it, XHTML is a way to serve up XML files as well as HTML (or something like that). If you’re not including XML files at all within the site then you should start with HTML 4.01 Strict. (Please correct me if I’m wrong!)
He made a typo when he implied <b> was deprecated, he probably meant to say something like <center> or the fact that a lot of people incorrectly use presentational elements to style and position text, etc.
Otherwise it was is more-or-less correct, i.e. the objective of trying to drop usage of clunky deprecated tags, attributes and better deployment of CSS for controlling layout, etc.
And yes - more questions - but I’ll read up on the The Definitive Guide to Web Character Encoding before I ask to many more apart from “What is AFAIK ?”
So from your response I take it that correct set up should be the
<?xml version=“1.0” encoding=“UTF-8”?> shown first then the DOCTYPE tag
Also what is the specific difference between the ‘strict’ and ‘transitional’ references?? within the DOCTYPE tag
Hi Chris Bell, welcome to the forums.
AFAIK having the XML declaration first id the correct way.
There are several things going on but I’ll do my best to give you my understanding (as good or as poor as it might be).
The first thing sent in response to a call to a web page are HTTP headers (Transfer Protocol) that indicate what’s about to be sent.
Most XHTML pages are sent as “bad” HTML. Partly because IE chokes on “real” XHTML. That is, the mark-up might be XHTML, but the browser will see it as improperly written HTML and do the best it can with it, surprisingly usually doing a good job.
When an XHTML page is sent with the leading XML declaration, it causes IE to go into quirks mode. Not that I can see what difference it makes any way, but I suppose it does depending on what markup and CSS the page is using.
As for the encoding, that can be specified in a few places. Maybe this SitePoint article will help?
The Definitive Guide to Web Character Encoding
Answer your question or raise more?
I think the original intent of the transitional Document Type Definition was to give people something to use while they were “changing over”. But in reality it’s more like “another” that’s joined the other flavors of HTML. As Far As I Know many sites still use very old DTDs even with HTML5 in the works.
Kind of like hosts still offering PHP4 and IE6 still being used. Rather than everything progressing in discrete steps, it just sort of widens the spread.
Doesn’t make things easier that’s for sure. Not only do you have to “keep up with the times” but you need to maintain backwards compatability.
Mittineague, Hi - sorry about my last post - didn’t realise that you had answered the ‘strict’ V ‘transitional’ question at the end of your response - I got way-laid with the UTF-8 scenario