/    Sign up×
Community /Pin to ProfileBookmark

Do I need these for XHTML?

<?xml version=”1.0″ encoding=”iso-8859-1″?>

<?xml-stylesheet type=”text/xsl” href=”copy.xsl”?>

<?xml version=”1.0″ encoding=”UTF-8″?>

What the heck are these? I’ve seen them mentioned in XHTML tutorials, and I’m wondering what they do and if I should use them in my XHTML site.

to post a comment
HTML

34 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 06.2004 — Do not use the XML declaration (<?xml version="1.0" ....) as it will put IE into "quirks mode".

Do use an encoding/charset in a meta tag or as a server side header.

http://www.webreference.com/authoring/xhtml/coding/

http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html

http://annevankesteren.nl/
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — Those are called processing instructions and as you've noticed they go in an XML document's prolog. The first and third are what they appear. They simply declare the version of XML and the encoding. The second is how one applies an XML Stylesheet Language (XSL).

It is a good idea to use them as required, XML defaults to utf-8 encoding and iso-8859-1 is a subset of utf-8, but there is no good reason for you to be using XHTML in the first place. XHTML does not always transition to HTML and you can cause trouble if you don't really know what you are doing. And if you are asking this question then you don't really know what you are doing.

Do not use XHTML.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — [i]Originally posted by Charles [/i]

[B]And if you are asking this question then you don't really know what you are doing.



Do not use XHTML. [/B]
[/QUOTE]


What if I'm creating an experimental web page to figure out what I'm doing? Or is that not allowed?

I saw them in a tutorial on W3C.
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — You are, of course, welcome to play but if you plan to publish XHTML on the web I would suggest that you closely follow the [url=http://www.w3.org/TR/xhtml1/#guidelines]HTML Compatibility Guidelines[/url] found in the XHTML 1.0 Spec.

XHTML does have its uses, but not on the web.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — Well...

I'm doing two things:

1) Using the W3C validator to make sure that my site's completely valid (and I won't take "tentatively valid" for an answer)

2) Testing my site in Opera, Firefox, Amaya, and IE, to make sure it works. Any other free browsers that work with windows you could suggest?
Copy linkTweet thisAlerts:
@FangOct 06.2004 — 1) Valid != correct. Think about accessibility, compatibility and semantics.

2) http://browsers.evolt.org/
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — I've heard semantics bandied about. What does it really mean?

Compatibility is why I test it on every browser I've got. (I HATE Amaya!)

As for accessability, what did you have in mind?
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — Make sure that you are using one of the Strict DTDs and that you are following the Web Content Accerssibility Guidelines 1.0.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — <?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="copy.xsl"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Those are my declarations. The second XML thing was something the W3C suggested to keep IEEEEE! from going bonkers. So, yes. I [i]am[/i] using strict.
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — If your provide the file "copy.xsl" then, yes, that is the proper way to go. But you'll need to post your XHTML file with an ".xml" extension. What that "copy.xsl" file does is describe how to map the XHTML to HTML.

MSIE at least, I don't know about the others, will not recognize your XHTML as XHTML unless it thinks that you are using XML. Now, XML and XHTML both have some really cool features. You can use entities to include fragments from other files. But browser support is limited. Mozilla for instance will not let you play with entities.

I repeat, XHTML is not simply HTML with a few stricter rules. It's a different animal and thus shouldn't be used for publishing something for the general public.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — Like, I already have the older website up, and it's in HTML 4.0 . I just wanted to redo it in XHTML, since I've gotten a few words from others on how HTML 4.0 (transitional and frameset) marks me as a n00b. *Sighs*
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — That's because HTML 4.0 was superseded by HTML 4.01 back in 1999. HTML 4.01 Strict remains the gold standard for web publishing.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — The guys who lambasted me (all on a group I won't mention due to etiquette) said XHTML was the gold standard...
Copy linkTweet thisAlerts:
@CharlesOct 06.2004 — Your "friends" are wrong. Ask them what benefit there is in using XHTML. If they tell you that it works on more browsers, that it is more accessible then laugh in their face. XHTML works on [i]fewer[/i] browsers than HTML and nothing works on more browsers than HTML 4.01 Strict. It is true, however, that if you use XHTML 1.0 Strict and follow the HTML Compatability Guidelines then you bring XHTML up to the level of HTML 4.01 Strict. But you have simply eliminated the damage. You haven't gained anything.

But you really should upgrade your HTML 4.0 pages. There were some problems with that version of HTML.
Copy linkTweet thisAlerts:
@FangOct 06.2004 — semantics; using elements correctly, tables for tabular data not layout, a list of anchors in a list, not a series of div's, tec.

It is impossible to test in every browser.

Following the guidelines of th W3C write your page using (x)html with elements in a logical order. Test this page in a text only browser.

Add CSS to implement the design requirements. Test this in browsers of your user group.

Accessibility; read the stickies at the [URL=http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=30]accessibility forum[/URL]
Copy linkTweet thisAlerts:
@David_HarrisonOct 06.2004 — [i]Originally posted by Fang [/i]

[B]Do not use the XML declaration (<?xml version="1.0" ....) as it will put IE into "quirks mode".[/B][/QUOTE]
Having IE in quirks is a good thing. It means that for all intents and purposes, IE5 and IE6 can be treated the same, so rather than writing styles for IE5, IE6 and the standards browsers, you only have to write styles for IE5/6 and the standards browsers.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — Hopefully the fact that the website is valid HTML 4.0 will make that job a bit easier...
Copy linkTweet thisAlerts:
@FangOct 06.2004 — [B]lavalamp[/B] wrote:

you only have to write styles for IE5/6 and the standards browsers[/QUOTE]

one style sheet no hacks!
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — Ummm... Why only one?
Copy linkTweet thisAlerts:
@FangOct 06.2004 — Do it right and you only need one CSS
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 06.2004 — I split my CSS up into different pages because I had several different color schemes, depending on what the pages were used for (links, library, novels, art, etc), and ended up with a CSS over 6 kb in size! >.<
Copy linkTweet thisAlerts:
@David_HarrisonOct 06.2004 — [i]Originally posted by Fang [/i]

[B]one style sheet no hacks![/B][/QUOTE]
I used to think like that, and if I recall correctly, I was able to create [url=http://www.fsg-uk.com/ahome.php]this web-site[/url] entirely without CSS hacks (although my CSS looked terrible back then, sorry). However when I moved on to more complex layouts I was unable to continue without using hacks and I eventually found them creeping more and more into my work.

While I realise that hacks are bad because future browsers may not be susceptable to the same hacks but still have the same dodgy CSS support, unfortunately I find that they are neccessary because otherwise I may as well just be banging my head against a brick wall.

I do try to keep the number of hacks present to a bare minimum and it would be lovely if I could get by without them, however I ... just ... can't. If you can then good for you, you must be better than I am.
Copy linkTweet thisAlerts:
@DaveSWOct 06.2004 — what hacks do you use then? ?

Since this might technically be hijacking the thread I've created a new thread for your responses!

http://www.webdeveloper.com/forum/showthread.php?s=&threadid=45926
Copy linkTweet thisAlerts:
@David_HarrisonOct 06.2004 — Ah, I found your thread before I found this. I did wonder if your thread was related to this one...
Copy linkTweet thisAlerts:
@Robert_WellockOct 07.2004 — It amuses me to some extent suggesting XHTML Strict 1.0, I assume not served as text/html because that kind of defeats the objectives.

Anyway I know why, basically I suppose you'd have to use the Transitional declaration but only use the Strict Elements and attributes to fall within the backwards compatibility mode – without sinking to HTML although then it poses the question; base browser.
Copy linkTweet thisAlerts:
@David_HarrisonOct 07.2004 — [i]Originally posted by Robert Wellock [/i]

[B]It amuses me to some extent suggesting XHTML Strict 1.0, I assume not served as text/html because that kind of defeats the objectives.[/B][/QUOTE]
Who suggested that? ?

You've gone and confused me now.
Copy linkTweet thisAlerts:
@jbotOct 07.2004 — [i]Originally posted by Robert Wellock [/i]

[B]It amuses me to some extent suggesting XHTML Strict 1.0, I assume not served as text/html because that kind of defeats the objectives. [/B]
[/QUOTE]


[i]Originally posted by lavalamp [/i]

[B]You've gone and confused me now. [/B][/QUOTE]


isn't XHTML meant to be a hybrid XML and HTML. so, the page get's served as XHTML. however, serving XHTML as HTML (ie XHTML-validated HTML) is meaningless. which brings us back to what Charles was saying before: that there's no advantage to declaring an XHTML doctype, because the document is not actually XHTML but mere HTML 4.01 Strict.
Copy linkTweet thisAlerts:
@FangOct 07.2004 — xhtml is xml, when done properly.

[B]Robert Wellock[/B] was refering to serving it as application/xhtml+xml which means adding:
&lt;?php
if(stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
header("content-type: application/xhtml+xml");
}
else {
header("content-type: text/html");
}
?&gt;

for browsers that understand xml
Copy linkTweet thisAlerts:
@jbotOct 07.2004 — [i]Originally posted by Fang [/i]

[B]xhtml is xml, when done properly.

[B]Robert Wellock[/B] was refering to serving it as application/xhtml+xml which means adding:

&lt;?php
if(stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
header("content-type: application/xhtml+xml");
}
else {
header("content-type: text/html");
}
?&gt;

for browsers that understand xml [/B][/QUOTE]


XHTML is not XML, but XML-ised HTML. to serve it you use "application/xhtml+xml". to serve XML, you'd use "application/xml". but the vast majority of pages which claim to be XHTML are not, since they merely serve "text/html". that "version" is basically a glorified HTML 5.
Copy linkTweet thisAlerts:
@FangOct 07.2004 — [URL=http://www.w3.org/International/articles/serving-xhtml/]from the W3C[/URL]

XHTML 1.0 can also be served as XML, and XHTML 1.1 is always served as XML. To serve XHTML as XML you use one of the MIME types application/xhtml+xml, application/xml or text/xml. The W3C recommends that you serve XHTML as XML using only the first of these MIME types - ie. application/xhtml+xml.[/QUOTE]
Copy linkTweet thisAlerts:
@David_HarrisonOct 07.2004 — [i]Originally posted by jbot [/i]

[B]isn't XHTML meant to be a hybrid XML and HTML. so, the page get's served as XHTML.[/B][/QUOTE]
That's not why I was confused...
Copy linkTweet thisAlerts:
@Robert_WellockOct 08.2004 — He was confused because it wasn't directly suggested; though it makes a mockery of thinking the XHTML Strict is better that Transitional.

In fact it's one big mockery that M$ Explorer doesn't really understand HTML 4.01 Strict either so it's a no win situation... that's what amused me so deeply.
Copy linkTweet thisAlerts:
@Stephen_PhilbinOct 08.2004 — [i]Originally posted by Robert Wellock [/i]

[B]

In fact it's one big mockery that M$ Explorer doesn't really understand HTML 4.01 Strict either so it's a no win situation... that's what amused me so deeply. [/B]
[/QUOTE]


The damned thing doesn't even understand doctypes, so how the hell it's gonna understand any versions of html I don't know. God I hope IE fades into obscurity fast.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 08.2004 — [i]Originally posted by Mr Herer [/i]

[B]The damned thing doesn't even understand doctypes, so how the hell it's gonna understand any versions of html I don't know. God I hope IE fades into obscurity fast. [/B][/QUOTE]


Then the web can GET somewhere. Like using XFrames... And better versions of CSS... and whatever...
×

Success!

Help @Mr_Initial_Man spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...