edpatterson
IS-IT--Management
- Feb 24, 2005
- 186
I am learning/trying to learn CSS from a book, Beginning CSS Web Development ... It eludes to the following
Then if offers the following html example to make use of the css, I saved as container.html
Only the text not within the container is red. The book stated that all of the text within the boxes would be red. and only the text directly in the container would be dark gray.
I am using Firefox 3.0.10 on a Ubuntu 9.04 machine, pages being served by Apache 2 if any of that matters.
It seems to me that since I am using 'box' within the 'container' that the 'box p' would be the one that wins out.
In fairness to the author of the book, the above is not an actual code sample, but since actual 'enter this/see that' examples are basically non-existent, I am making my own samples.
For those with access to the book, I am refering to pages 42 and 43.
Thanks
Code:
/* I saved this as container.css */
/* Define styling of our reusable box */
.box {
margin: 10px;
padding: 20px;
border: 1px solid #000;
}
/* Make text red only for paragraphs within the box class */
.box p {
color: #F00;
}/* Container holds all visible page elements */
#container {
padding: 20px;
border: 1px solid #000;
background: #CCC;
}
/* Make text gray only for paragraphs within the container */
#container p {
color: #333;
}
Code:
<html>
<head>
<title>Container Example</title>
<style type="text/css">@import url("css/container.css");</style>
</head>
<body>
<div id="container">
Content
<div class="box">
<p>I'm in a box</p>
</div>
<div class="box">
<p>I'm also in a box</p>
</div>
</div>
<div class="box>
<p>I'm also in a box!
</p>
</div>
</body>
</html>
I am using Firefox 3.0.10 on a Ubuntu 9.04 machine, pages being served by Apache 2 if any of that matters.
It seems to me that since I am using 'box' within the 'container' that the 'box p' would be the one that wins out.
In fairness to the author of the book, the above is not an actual code sample, but since actual 'enter this/see that' examples are basically non-existent, I am making my own samples.
For those with access to the book, I am refering to pages 42 and 43.
Thanks