Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Problem with styles converting from HTML to XHTML

Reply
Thread Tools

Problem with styles converting from HTML to XHTML

 
 
Oli Filth
Guest
Posts: n/a
 
      12-13-2004
I'm in the process of converting a website from HTML 4 (Transitional) to XHTML
Transitional. It all validates fine, but I now have a problem with the CSS
styles thar are being inherited.

Take a look at the sample page at http://olifilth.co.uk/test.htm.

==== BEGIN HTML CODE ====

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Test CSS in XHTML</title>
</head>
<body style="background-color: #666">
<div style="color: #FFF; font-size: 24px">
Some text that is white and 24px (and should be).
<table><tr><td>
Some text that is black and small (should be white and 24px ???).
</td></tr></table>
</div>
</body>
</html>

===== END HTML CODE =====

Both lines of text are within a <div> element with some styles defined; the
second line is nested within a <table><tr><td> element. In Firefox 1.0, both
lines of text take on the styles defined in the <div> tag. However, in IE6, only
the first line takes on the style, the second line reverts to a default format.

Both lines took on the defined style when the document was defined as HTML 4
(Transitional) in IE6. So which browser is showing the XHTML version correctly?

Thanks in advance,
Oli
 
Reply With Quote
 
 
 
 
Steve Pugh
Guest
Posts: n/a
 
      12-13-2004
On Mon, 13 Dec 2004 17:55:47 GMT, Oli Filth
<(E-Mail Removed)> wrote:

>I'm in the process of converting a website from HTML 4 (Transitional) to XHTML
>Transitional.


Converting from HTML 4 Transitional to HTML 4.01 Strict would be a
better use of time.

> It all validates fine, but I now have a problem with the CSS
>styles thar are being inherited.
>
>Take a look at the sample page at http://olifilth.co.uk/test.htm.
>
>==== BEGIN HTML CODE ====
>
><?xml version="1.0"?>


This causes IE to go into quirks mode.

><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
><html>
><head>
> <title>Test CSS in XHTML</title>
></head>
><body style="background-color: #666">
> <div style="color: #FFF; font-size: 24px">
> Some text that is white and 24px (and should be).
> <table><tr><td>
> Some text that is black and small (should be white and 24px ???).
> </td></tr></table>
> </div>
></body>
></html>
>
>===== END HTML CODE =====
>
>Both lines of text are within a <div> element with some styles defined; the
>second line is nested within a <table><tr><td> element. In Firefox 1.0, both
>lines of text take on the styles defined in the <div> tag. However, in IE6, only
>the first line takes on the style, the second line reverts to a default format.


Yep. IE6 is in quirks mode so emulates the bugs of IE5. Get rid of the
XML declaration and IE6 will behave itself (IE5 will still get things
wrong though).

>Both lines took on the defined style when the document was defined as HTML 4
>(Transitional) in IE6. So which browser is showing the XHTML version correctly?


If were using a HTML 4 Transitional doctype that triggers standards
mode then yes IE6 would get things right in that case.

Steve

 
Reply With Quote
 
 
 
 
Oli Filth
Guest
Posts: n/a
 
      12-13-2004
Steve Pugh wrote:
> On Mon, 13 Dec 2004 17:55:47 GMT, Oli Filth
> <(E-Mail Removed)> wrote:
>
>
>>I'm in the process of converting a website from HTML 4 (Transitional) to XHTML
>>Transitional.

>
>
> Converting from HTML 4 Transitional to HTML 4.01 Strict would be a
> better use of time.
>
>


I've chosen the XHTML route after reading up that XHTML 1.0 is the W3C's
recommendation for adopting standards, according to their own website and
others. As far as I can make out, it's basically a cleaner, stricter and more
standardised definition of HTML 4.01, which appeals to me as an anal retentive.

> Yep. IE6 is in quirks mode so emulates the bugs of IE5. Get rid of the
> XML declaration and IE6 will behave itself (IE5 will still get things
> wrong though).
>


Aha, indeed it does. Thank you!

Oli
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      12-13-2004
Oli Filth wrote:

> <table><tr><td>
> Some text that is black and small (should be white and 24px ???).
> </td></tr></table>


IE/win has some inheritance problems inside tables.

Try dropping the XML prologue -- that shoulf flick it into standards mode
and you may get better results.

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

 
Reply With Quote
 
Spartanicus
Guest
Posts: n/a
 
      12-13-2004
Oli Filth <(E-Mail Removed)> wrote:

>I've chosen the XHTML route after reading up that XHTML 1.0 is the W3C's
>recommendation for adopting standards, according to their own website


Wrong.

>and
>others. As far as I can make out, it's basically a cleaner, stricter and more
>standardised definition of HTML 4.01, which appeals to me as an anal retentive.


http://www.spartanicus.utvinternet.ie/no-xhtml.htm

--
Spartanicus
 
Reply With Quote
 
Neal
Guest
Posts: n/a
 
      12-13-2004
On Mon, 13 Dec 2004 17:55:47 GMT, Oli Filth
<(E-Mail Removed)> wrote:

> I'm in the process of converting a website from HTML 4 (Transitional) to
> XHTML Transitional.


Why?

Your problems stem from IE's inability to handle valid XHTML. As such,
it's really no more than an academic exercise to use XHTML at all at this
point. It offers no extra value to most UAs in use.

I'd work on upgrading to HTML 4.01 Strict and separating the
decoration/presentation from the meaning/content, and putting that in an
external CSS stylesheet. Far better use of your time.
 
Reply With Quote
 
C A Upsdell
Guest
Posts: n/a
 
      12-14-2004
"Neal" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Mon, 13 Dec 2004 17:55:47 GMT, Oli Filth
> <(E-Mail Removed)> wrote:
>
>> I'm in the process of converting a website from HTML 4 (Transitional) to
>> XHTML Transitional.

>
> Why?
>
> Your problems stem from IE's inability to handle valid XHTML.


Why is it that, having used xHTML since it came out, I have NEVER had a
problem with how IE handles it? I must be living a blessed life, never
having had a problem with "IE's inability to handle valid XHTML".






 
Reply With Quote
 
C A Upsdell
Guest
Posts: n/a
 
      12-14-2004
"Neal" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Mon, 13 Dec 2004 17:55:47 GMT, Oli Filth
> <(E-Mail Removed)> wrote:
>
>> I'm in the process of converting a website from HTML 4 (Transitional) to
>> XHTML Transitional.

>
> Why?
>
> Your problems stem from IE's inability to handle valid XHTML.


Why is it that, having used xHTML since it came out, I have NEVER had a
problem with how IE handles it? I must be living a blessed life, never
having had a problem with "IE's inability to handle valid XHTML".







 
Reply With Quote
 
Neal
Guest
Posts: n/a
 
      12-14-2004
C A Upsdell:

> Why is it that, having used xHTML since it came out, I have NEVER had a
> problem with how IE handles it? I must be living a blessed life, never
> having had a problem with "IE's inability to handle valid XHTML".


Mind you, IE can handle XHTML well provided:

1) You serve it as text/html, which is really the wrong MIME for XHTML
2) You omit the prolog which knocks IE into quirks

But by doing that, you serve a bastardized version of XHTML. Why bother?

In other words, what benefit does XHTML provide in that event?
 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      12-14-2004
C A Upsdell wrote:
> "Neal" <(E-Mail Removed)> wrote in message


> > Your problems stem from IE's inability to handle valid XHTML.

>
> Why is it that, having used xHTML since it came out, I have NEVER had a
> problem with how IE handles it? I must be living a blessed life, never
> having had a problem with "IE's inability to handle valid XHTML".


Then you have not been sending true XHTML to the browsers.

IE can only accept XHTML if it is served up as HTML. If you send a page to
IE with a MIME type of application/xhtml+xml then IE will ask you if you
want to download it.

Visit this page with firefox, just to reassure yourself that it is, in fact,
a true XHTML page.
http://juicystudio.com/mimetest/xhtmldoc.asp

Then visit it with IE.

--
Cheers
Richard.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs XML 0 08-02-2011 05:40 AM
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs C Programming 0 08-01-2011 06:29 AM
How to tell VS to wite HTML element's styles in the CSS file automaticly instead of in the body of the HTML file. oranmeir@gmail.com ASP .Net 1 06-09-2006 06:53 AM
Converting HTML to XHTML (JTidy,OpenXML,Xerces) anupamjain@gmail.com Java 9 03-24-2006 01:35 PM
.net library/class/component for converting HTML into XHTML? darrel ASP .Net 1 09-09-2004 01:39 PM



Advertisments