Hello, I wrote a simple html and css files and according to css rules the first and the third paragraph should be red because they are direct descendents of <body> but don't work and I see all three black could you help me, please?
thanks!
I must always start your document with a Doctype. Without a Doctype, browsers (mainly IE) enter in "quirks mode", which will spoil the CSS/JavaScript/ and even HTML/XHTML standard behavior.
So:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
//...
//...
</html>
I've writed the doctype but all three paragraph are yet black
Impossible. This document:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
body > p {color: red;}
</style>
</head>
<body>
<p>Red text</p>
<div>
<p>black text</p>
</div>
<p>Red text</p>
</body>
</html>
Does exactly what you want. Tested in IE7, IE8, IE9, FF4, Chrome 11, Opera 11, Maxthor 2 / Win7 . Of course, it won't work in IE 6, but that is understandable. IE6 is a medieval browser, which is on his way to be extinct soon.
Bookmarks