faqts : Computers : Internet : Web : CSS

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

Why doesn't my HREF inherit from the container above, even though I use the > selector?

Apr 25th, 2002 00:09
mirthe valentijn,


Never mind. I've figured it out myself. Just in case you're interested, 
the following works. The HREFs inherit from the CONTAINTER, so you 
don't have to specify classes for each link that's different (like 
menu's or footers, as I used to do).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title> Test with inheritence </title>

<style type="text/css"><!--
.container 		{color: red; border: black 1pt solid; 
			padding: 10px; width: 35%;}
.container a 		{color: red;}
.container strong 	{color: green; font-weight: bold;}
--></style>

</head><body>

<div class="container">
	<p><a href="test.htm">a link in the containter 
	(should be red)</a></p>
	<p><strong>bold text in the containter 
	(should be green and bold)</strong></p>
	<p>text in the containter 
	(should be red)</p>
</div>

<p><a href="test.htm">a link outside the containter 
(should be black)</a></p>
<p><strong>some bold text outside the containter 
(should be black and bold)</strong></p>
<p>some text outside the containter (should be black)</p>

<p>Info on selectors: 
<a href="http://www.w3.org/TR/REC-
CSS2/selector.html">http://www.w3.org/TR/REC-CSS2/selector.html</a></p>

</body></html>


Hope this is clear. Enjoy.
-Mirthe