W3C home > Mailing lists > Public > www-style@w3.org > November 2005

Re: [css21] aligning HTML and XHTML

From: Bert Bos <bert@w3.org>
Date: Mon, 14 Nov 2005 12:16:53 +0100
To: "www-style@w3.org" <www-style@w3.org>
Message-Id: <200511141216.53451.bert@w3.org>

On Saturday 12 November 2005 01:51, Anne van Kesteren wrote:
> I was wondering, now that CSS 2.1 is at last call again, if it could
> be changed in such a way that HTML and XHTML would be more aligned.
> From what I recall, (except for issues that are really different like
> case-sensitivity) 'overflow' and 'background' propagation from the
> HTML "BODY" element (which is a first child of the root element
> called "HTML") are the differences.

I agree that there is, maybe not a problem, but at least an 
inconvenience in using XHTML1.

The special rule for BODY is not very elegant, but it was a necessity 
back in the days that CSS was still trying to get accepted and browsers 
didn't treat HTML as a tree structure.

The fact that XHTML1 exists isn't a great help either. It has not enough 
differences from HTML to be useful as a format on its own and just 
enough to be confusing.

The result is that people try to use the same style sheet for HTML and 
XHTML1 and encounter subtle problems.

The best solution would be to use different style sheets for different 
formats, but the tools to help with that aren't very sophisticated yet. 
E.g., browsers typically only have a single user style sheet for all 
formats. And Amaya and Tidy, two tools often used to convert between 
HTML and XHTML1, change the document syntax, but don't do anything with 
style sheets. They don't even warn.

Here is a hack I use for the background in shared style sheets:

  html {background: white; color: black}   /* For XHTML */
  HTML {background: none; color: inherit}  /* Undo the above for HTML */
  BODY {background: white; color: black}   /* For HTML */

XHTML1 was designed to help people get used to XML and the 
inconveniences are thus on purpose :-)



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Monday, 14 November 2005 11:16:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:41 GMT