473,769 Members | 4,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1858
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 "applicatio n/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

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

Similar topics

16
7117
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"); MyDiv.appendChild(iframeObject); var data = "<html><head><title>testing</title></head><body>data</body></html>" iframeObject.contentDocument.open(); iframeObject.contentDocument.writeln(data);
12
2415
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
433
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
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.