Re: background-color:transparent vs. background-color:inherit

From: pierre@netscape.com (Pierre Saslawsky)
Date: Tue, Mar 28, 2000, 10:34 PM
>
> Visually speaking, what is the difference between
> 'background-color:transparent' and 'background-color:inherit'?

Pretty big visual difference.

background-color:transparent will allow anything underneath to show through -
that means any content, background images, borders etc. of elements that this
element happens to be drawn over.

background-color:inherit will take the background color of its parent, and
draw over anything that is overlapped, including the background-image (if any)
of its parent.


> Note: the
> latter was not legal in CSS1, it came with CSS2.

Yes, a correct CSS1 browser should ignore background-color:inherit.

This page actually demonstrates this in the CSS1 test suite:

http://www.w3.org/Style/CSS/Test/current/sec71.htm

Check out the paragraph (P.two - which is actually the third test paragraph)
which says:

"This paragraph should have a solid gray background (or a white grid), because
in CSS1, inherit is an invalid keyword, and in CSS2, it will cause the gray
background (not the white grid) to be inherited. "

Try this in IE5/Mac (which supports "inherit" for all CSS properties per
CSS2), and it shows a gray background for that paragraph.   "transparent"
would have allowed the white grid to show through.

Tantek

Received on Wednesday, 29 March 2000 02:02:00 UTC