Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with CSS Inheritance?

0 views
Skip to first unread message

Paul A. Scott

unread,
Nov 10, 2002, 2:54:49 AM11/10/02
to
In the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"/>
<title>XHTML TEST</title>
<style type="text/css"><!--
#divroot {
border: 1px;
border-style: dotted;
text-align: center;
text-color: darkgreen;
}
--></style>
</head>
<body>
<div id="divroot">
<table><tr><td>XHTML TEST</td></tr></table>
</div>
</body>
</html>

I would expect the text "XHTML TEST" to be centered in the browser window.
In IE 6 and prior it is left justified. Why? The DIV element uses the
text-align: css attribute which is allowed for DIV and all the descendants
in the example. So why doesn't TD inherit text-align: ???

Is this another but in IE?


Paul A. Scott
mailto:psc...@skycoast.us
http://skycoast.us/pscott/

Paul A. Scott

unread,
Nov 10, 2002, 5:12:50 PM11/10/02
to
In my previous post I stated that in IE 6 the text "XHTML TEST" was left
justified although it should have been centered.

In truth, under IE 6 on MS Windows it is centered as expected. The problem
seems to be in the inheritance rules for MS IE 5.2.2 on Mac OSX. In fact,
these two browsers from MS operate in very different ways on many of the
CSS1 properties.

Worse, neither browser handles all the CSS1 properties correctly, AFAIK. IE
6 seems to do a better job on most, but is still not perfect.

Netscape is way out there. I don't even want to talk about it.

It's very sad that CSS is supposed to make formatting more consistent, and
yet with CSS we have to play stupid programmer tricks just like we do with
HTML. I guess all we can do is hope that MS and others get it right soon.

What's a programmer to do?

Erik Arvidsson

unread,
Nov 17, 2002, 7:11:01 PM11/17/02
to
The text should actually be left justified. The reason is that the display
property of a table is by default "table", not "inline-table". Text-align
only aligns text and inline element children, not block element children.

This becomes much clearer if you set a background on your table. You might
also want to set a width to the table to see whether the browser inherits
the text-align. I noticed that Moz 1.3 inherited the text-align, while Opera
7 beta 1 did not. IE6 in strict inherited, but IE6 in back compat mode did
not.

As a side note; The usage of display "table" and display "inline-table"
might help you achieve what you want in browsers that support this. (IE does
not understand this but if you set display to inline on a table you will the
inline-table behavior.)

What a mess :-)

erik

"Paul A. Scott" <psc...@skycoast.us> wrote in message
news:B9F350C9.F914%psc...@skycoast.us...

0 new messages