473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Validing XHTML vs Html

Hello,

If my html is valid XHTML accroding to http://validator.w3.org/, does
thuis mean it is also valid (4.0.1) Html?

Thanks in Advance

Mar 2 '06 #1
13 1817
On 2 Mar 2006 02:49:28 -0800, "Peter Williams" <p8****@gmx.net> wrote:
If my html is valid XHTML accroding to http://validator.w3.org/, does
thuis mean it is also valid (4.0.1) Html?


Hi Peter. A test you could try is to make a copy of a file, change the
DOCTYPE, and then try to re-validate it.

XHTML is usually served up with the MIME type "text/html", which means
that browsers see it as HTML, and render it correctly. This is because
XHTML was designed for backwards-compatability. Another way of saying
this is that XHTML is broken HTML that happens to be broken in just
such a way that it doesn't break the page. It is not valid HTML 4.01,
though, to answer your question.

The real MIME type for XHTML is "application/xhtml+xml", which most
browsers recognize, but which Internet Explorer doesn't recognize.
Since IE commands most of the market share, and since they're not
going to accomodate this MIME type in IE 7, a lot of web designers
have gone back to HTML 4.01. I've done the same thing. I actually
learned XHTML first, and stuck with it for many years. If you use a
text editor that supports HTML Tidy, then making the conversion back
to HTML 4.01 is as simple as changing the DOCTYPE and then tidying the
page.

Ian
--
http://sundry.ws/
Mar 2 '06 #2
Peter Williams wrote:
If my html is valid XHTML accroding to http://validator.w3.org/, does
thuis mean it is also valid (4.0.1) Html?


Obviously the doctypes will be different - a valid HTML 4.01 document
should have a HTML 4.01 doctype and a valid XHTML 1.0 document should
have a XHTML 1.0 doctype.

But ignoring that (and the whole content-type farce), if you swapped
doctypes (or used the over ride feature in the validator) would it be
valid? Maybe.

If your XHTMLisms are confined to those that look like HTMLisms then it
will be valid.

So, you would need to have:
* No empty elements in the head (so no <link> or <meta> elements) or
anywhere else where character data can't appear.
* No boolean attributes anywhere (so no compact, readonly, disabled or
nowrap attributes).

Of course there are valid XHTMLisms that look like valid HTMLisms but
which mean something totally different in HTML (e.g. <br /> means <br>>
not <br></br>).

Steve

Mar 2 '06 #3
Steve Pugh wrote:
Peter Williams wrote: If your XHTMLisms are confined to those that look like HTMLisms then it
will be valid.

So, you would need to have:
* No empty elements in the head (so no <link> or <meta> elements) or
anywhere else where character data can't appear.
Although any of those used where character could appear would have
different meaning in HTML than in XHTML.
* No boolean attributes anywhere (so no compact, readonly, disabled or
nowrap attributes).


HTML does allow for the expanded form of boolean attributes, it just
isn't recomended.

http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.4

Mar 2 '06 #4
Peter Williams wrote:
If my html is valid XHTML accroding to http://validator.w3.org/, does
thuis mean it is also valid (4.0.1) Html?


No, it certainly doesn't _mean_ that.

If you didn't use certain features, and you swap the doctype, then it
_may_ be valid as both.

It's not really useful to know this though. They are different and they
do need separate processing. Searching this newsgroup is probably the
best resource around on the details. If you don't _really_ understand
this, then stick with HTML 4.01

Mar 2 '06 #5
David Dorward wrote:
Steve Pugh wrote:
* No boolean attributes anywhere (so no compact, readonly, disabled or
nowrap attributes).


HTML does allow for the expanded form of boolean attributes, it just
isn't recomended.

http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.4


Thanks, I'd never come across that before.

Steve

Mar 2 '06 #6
Andy Dingley wrote:
If my html is valid XHTML accroding to http://validator.w3.org/, does
thuis mean it is also valid (4.0.1) Html?
No, it certainly doesn't _mean_ that.


Indeed; it means that the document _cannot_ be valid HTML 4.01.
If you didn't use certain features, and you swap the doctype, then it
_may_ be valid as both.
Well, it's not the same document any more if you swap the doctype.

Besides, a document that conforms to the XHTML specification does not
become a (valid) HTML 4.01 document just by swapping the doctype, even
if we ignore issues already discussed here. The xmlns attribute is
obligatory, though for technical reasons, it is not required as an
explicit attribute according to the DTD. (Thus, an XHTML document that
lacks the attribute is valid but incorrect, nonconforming.)

An XML declaration (<?xml ...>) at the start of document, as allowed in
XHTML, makes a document nonconforming (though not invalid) by HTML 4.01
rules.

There are also differences in content models of <script> and <style>
elements. They can be essential if you have "&" or "<" characters inside
them.
It's not really useful to know this though.


Yeah, it's just fun to get confused with this. However it _is_ an issue,
in principle at least, if you wish to author so that you serve the same
content as HTML 4.01 to some browsers and as XHTML to other browsers.
Mar 2 '06 #7
> However it _is_ an issue, in principle at least, if you wish to author so that you serve the same content as HTML 4.01 to some browsers and as XHTML to other browsers.

This is what Im aiming at.

Mar 3 '06 #8
I suppose my original question should have better have been phrased:

Apart form some trivialities (eg swapping DOCTYPE) correct XHTML is a
superset of correct HTML ? So that by writing correct XHTML and
avoiding anything outside the overlap (XHTML thats not part of HTML),
the result will be even more "standard" than correct HTML (ie all
elements properly closed etc)?

Or are the trivialities not so simple, so that it wouldnt be so trivial
to convert my XHTML documents to HTML, by hand via simlpe editing such
as swapping of the DOCTYPE? Are there things to be weary of here?

Mar 3 '06 #9
Peter Williams wrote:
However it _is_ an issue, in principle at least, if you wish to author so that you serve the same content as HTML 4.01 to some browsers and as XHTML to other browsers.

This is what Im aiming at.


Peter,

How brave are you?

Back up all your files, then go to w3.org and download the appropriate
version of Amaya.

Open a file, then:

File, Show parsing errors (unless it's greyed out). Fix the errors.

File, Change the Document Type. Pick one. Let it crank a while. Then
File, Save as...

CAUTION: This code is under test. Bad Things can happen. Proceed at
your own risk.

Chris Beall
Mar 3 '06 #10
"Jukka K. Korpela" <jk******@cs.tut.fi> writes:
An XML declaration (<?xml ...>) at the start of document, as allowed
in XHTML, makes a document nonconforming (though not invalid) by HTML
4.01 rules.


The general policy of W3C HTML – as far as I know it – is a vague “‘foo’
is recommended” rather than an explicit “‘bar’ is Verboten”. *If*
processing instructions in the prolog are nonconforming, HTML cannot be
processed by any conforming SGML system as a conforming application in
the first place. End of story (obfuscating nsgmls output with
undocumented heuristics, as the W3C validation service happens to do,
does not rewrite standards; no surprise, but that qualifies 'invalid' as
undefined).
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Mar 3 '06 #11
Peter Williams wrote:
Apart form some trivialities (eg swapping DOCTYPE) correct XHTML is a
superset of correct HTML ?


Not really.

Apart from swapping the DOCTYPE, it is possible to create a document that
is both valid HTML *and* valid XHTML. For example, given the right
DOCTYPE, the following markup is valid HTML 4.01 and XHTML 1.0:
[listing 1]
<html lang="en">
<head>
<title>Example.</title>
</head>
<body>
<h1>Example.</h1>
<p>This is an example.</p>
</body>
</html>

However, the following valid HTML document would not be valid as XHTML:
[listing 2]
<html lang="en">
<title>Example.</title>
<h1>Example.</h1>
<p>This is an example.
</html>

and the following XHTML would not be valid as HTML:
[listing 3]
<html xml:lang="en">
<head>
<title>Example.</title>
<meta name="title" content="Example."></meta>
</head>
<body>
<h1>Example.</h1>
<p>This is an example.</p>
</body>
</html>

So, if we're going to talk subsets and supersets (and forget about
DOCTYPES) then:

If H is the set of all possible valid HTML documents; and X is the set of
all possible valid XHTML documents, then there exists a non-empty set A
such that A⊂H and A⊂X, as illustrated by listing 1, which is a member
of set A.

However, as shown by listing 2, there exists a document h such that h∈H,
but h∉X. And as shown by listing 3, there exists a document x such that
x∉H, but x∈X. These last two findings show that H⊄X and X⊄H.

FWIW, I think that whether you're using XHTML or HTML, it's usually good
practice to aim for your documents to be as close to set A as possible.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Mar 4 '06 #12
On 3 Mar 2006 02:56:26 -0800, "Peter Williams" <p8****@gmx.net> wrote:
Apart form some trivialities (eg swapping DOCTYPE) correct XHTML is a
superset of correct HTML ?


No.

You should read Hixie's paper. This paper is bogus, because it describes
difficulties in achieving something that no-one wants to do - but it
seems that you actually want to !

HTML and XHTML should be seen as two separate end results of diverging
content-management tasks. It's usually easy to produce either on demand
but his idea of "simultaneously being both" is both impossibly
difficult, and pointless.

Mar 6 '06 #13
On Mon, 6 Mar 2006, Andy Dingley wrote:
You should read Hixie's paper. This paper is bogus, because it
describes difficulties in achieving something that no-one wants to
do
Oh, I dunno about that - I've seen several cases of people who
appeared to want to do what it describes (that is, until it was
explained to them what they'd need - and then they went right off the
idea).

The problem with Hixie's paper is that it over-states the case with
such details, giving people who want to diss it ("bogus", your choice
of words) the opportunity to ignore the substantive message which it
also contains.
HTML and XHTML should be seen as two separate end results of
diverging content-management tasks. It's usually easy to produce
either on demand but his idea
"his" idea? That isn't how I read it.
of "simultaneously being both" is both impossibly difficult, and
pointless.


No disagreement there. But I don't interpret that as Hixie's point,
and it doesn't contradict the substantive content of his rant.

One message that I take from his rant is that the majority of
soi-disant "XHTML" on the web today is in fact XHTML-flavoured tag
soup, fit only to be served as text/html under the extensive fixup
heuristics of bad old HTML. As genuine XHTML, it is bogus: as
"XHTML/1.0 Appendix C" it is bogus too. It carries all of the old
ballast of only "working" (for some small values of the term
"working") in the presence of a whole menagerie of browser fixups.

So the provisions of "Appendix C" have given us a whole new legacy of
defective markup, containing all of the disadvantages which had
accrued in HTML du jour, and from which XHTML was supposed to rescue
us, PLUS some whole new legacy problems based on widespread
misunderstandings of XHTML and of Appendix C.

It would have been better to convince those authors to stay with
legacy HTML unless/until they understood XHTML. And draw a firm line
under the fixup heuristics of HTML, make a clean break and a clean
start. But it's too late for that now: the new legacy is already
there. Ho hum.
Mar 6 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Mcginkel | last post by:
I am trying to find a way to load XHTML content in an Iframe. I use to do this in html by using the following code : var iframeObject = document.createElement("iframe");...
12
by: Alex D. | last post by:
How can I stop asp.net from rendering XHTML istead of HTML? My javascripts are rendering wrong because of that. It is rendering &amp; to clients instead of &. Any help? Thanks, Alejandro.
6
by: Guy Macon | last post by:
cwdjrxyz wrote: HTML 5 has solved the above probem. See the following web page: HTML 5, one vocabulary, two serializations http://www.w3.org/QA/2008/01/html5-is-html-and-xml.html
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.