Hi, new person here

I am just starting to learn css and it’s no where as easy as I thought it would be. yeah. I know surprise!
even this easy sample only shows a blue bar at the top & when I tried to edit the image by adding height & width, the image just disappears. & the string at <div> never showed up in the first place
I pasted the code, any advice is appreciated. Thanks you all!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN"  

"http://www.w3.org/R/xhtml1/DTD/xhtml1-strict.dtd">



<html>
    <head>
        <title> content property </title>
            <style type="text/css" media="all">

div{
    content: "this string is placed inside all div elements.";
    border: thick solid blue;
    background: skyblue;
    color: green;
    font-size: xx-large;
    padding: 10 px;
}


        </style>
    </head>


<img src= "images/bigBlueMarble.jpg>


<body>
    <div></div>
    <div></div>
</body>

</html>

I also read that mozilla doesn’t support the “content”.

Only in very very old mozilla. The content property is supported in all modern browsers and it’s only IE6 and 7 that you need to worry about as far as support goes. Nearly all other browsers have supported it for years.

string: this string is placed inside all div elements.;

That’s not a CSS property and won’t work :slight_smile:

It might help if we knew what the layout was supposed to look like unless you are just testing things out for practice of course.

OHHHH. one of Simons’s cat! love it!

Thank you both for your time. I realize my questions must come across as pretty stupid right now.
Any advice on: placing a back ground image using this bit of code in the styles.css
body {
margin:0;
padding: 0;
color: #00ffff;
background-image: url(blueMarble.jpg);
background-repeat: repeat-x;
font: small Arial, helvetica, Verdana, sans-serif;
}
Using this link in the html but the browers doesn’t show it at all.
<link re=“stylesheet” type=“text/css” href=“styles.css”>

two: using this type of div in the htlm not gotten to do anything w/the css yet.

<div id=“header”>
<p>home of the hack</p>
<ul>
<li><a href=“”>Contact us</a></li>
<li><a href=“”>About us</a></li>
<li><a href=“”>Privacy</a></li>
<li><a href=“”>Site map</a></li>
</ul>
</div><!–header–>

three: Can you advise as to best & quickly learn w/out peppering this site & your folks w/stupid questions? is there a great book I can use?
Thank you again.
daniela

Thanks Stevie will go back & try some more!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN"  

"http://www.w3.org/R/xhtml1/DTD/xhtml1-strict.dtd">



<html>
    <head>

        <title> content property </title>
            <style type="text/css" media="all">

div{
    
    border: thick solid blue;
    background: skyblue;
    color: green;
    font-size: xx-large;
    padding: 10px;
    string: this string is placed inside all div elements.;

}


p{
    font-size: 1in;
    color: black;
    margig: 0;
}


        </style>
    </head>






<body>
    <div></div>
    <div></div>

</body>

It really helped and thank you for taking the time to give me all the info.
I also read that mozilla doesn’t support the “content”.
so since I am just starting out I am trying to figure out how to best do this.
Thank you again for your work and looking in my code
Daniela

Hi,

Welcome to Sitepoint :slight_smile:

The content property is only used in conjunction with the [URL=“http://reference.sitepoint.com/css/pseudoelement-before”]:before and [URL=“http://reference.sitepoint.com/css/pseudoelement-after”]:after pseudo classes (not supported in IE6 and 7) and cannot be used in the manner you have above. It should be used like this:


div:after{content: "this string is placed inside all div elements [B]after[/B] the content in that div.";}
div:before{content: "this string is placed inside all div elements [B]before[/B] the content in that div.";}

As an aside you should not use generated content for important content as that should be in the html as normal.

when I tried to edit the image by adding height & width, the image just disappears.

You have the image outside of the body element and it should be inside it. You have also missed the closing quote from the image src attribute and also added a space between the src attribute and the opening quote.

It should look like this:


<body>
<img src="images/bigBlueMarble.jpg" width="300" height="100" alt="example image" />

Although the image should itself be in a block level box to keep things nicely in order.


<body>
<p><img src="images/bigBlueMarble.jpg" width="300" height="100" alt="example image" /></p>

You have a gap between the dimension and the unit in your padding.


padding: 10 px;


It should be:


padding:[B]10px[/B];


Copy your page code and run it through the validator to see a list of errors that it produces as the doctype seems broken also.

The keyword skyblue is not a valid css keyword and you should use the hex equivalent.

Valid code would look like this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css" media="all">
div {
    border:2px solid blue;
    background:#87ceeb;
    color: green;
    font-size: xx-large;
    padding:10px;
}
div:after {
    content: "this string is placed inside all div elements.";
}
</style>
</head>
<body>
<p><img src="images/bigBlueMarble.jpg" width="300" height="100" alt="example image" /></p>
<div></div>
<div></div>
</body>
</html>

Of course that makes no allowances for semantics as I’m guessing this is just a test but if that image is supposed to be a heading then it should be in a heading tag (h1).

Also as mentioned above there is no content in the html so the generated content should only be decorative and not important to the content otherwise it should be in the html by default as users with css switched off get a blank page.

Hope that helps :slight_smile:

Not at all - we all had to start somewhere!

Any advice on: placing a back ground image using this bit of code in the styles.css

body {
margin:0;
padding: 0;
color: #00ffff;
background-image: url(blueMarble.jpg);
background-repeat: repeat-x;
font: small Arial, helvetica, Verdana, sans-serif;
}

Using this link in the html but the browers doesn’t show it at all.
<link re=“stylesheet” type=“text/css” href=“styles.css”>

It should be rel, not re, in the <link>.

two: using this type of div in the htlm not gotten to do anything w/the css yet.

<div id=“header”>
<p>home of the hack</p>
<ul>
<li><a href=“”>Contact us</a></li>
<li><a href=“”>About us</a></li>
<li><a href=“”>Privacy</a></li>
<li><a href=“”>Site map</a></li>
</ul>
</div><!–header–>

Nothing technically wrong with that (except of course that you will need something in the href=“” bits!), but would it be better to have “home of the hack” in a heading element, eg <h1> or <h2> if it’s a heading, rather than a <p>?

three: Can you advise as to best & quickly learn w/out peppering this site & your folks w/stupid questions? is there a great book I can use?

There are lots of books, and lots of articles all over the place. The Sitepoint Reference section of the website (scroll up and it’s there on the blue bar) is a great place for accurate and detailed information about all the different HTML elements and CSS properties. There are also a load of Sitepoint books available (I know I’m sounding a bit like a salesman, but really, they are good!).

Still a few things not right.

You can’t put content in the CSS - it needs to go in the body. So get rid of string: this string is placed inside all div elements.; and in the body, put <div>this string is placed inside all div elements.</div> instead of those empty divs.

It’s better not to use keywords for sizing (eg border: [COLOR="Red"]thick[/COLOR] solid blue; font-size: [COLOR="#ff0000"]xx-large[/COLOR];), as browsers can interpret them differently. It’s better to give border thickness in px, and font size in either em or %. Don’t use physical measurements like in or cm unless it is a stylesheet specifically for printing and not for screen use.

Although most browsers support 140 named colours, including ‘skyblue’, it isn’t technically correct, and so may not work in some browsers. You can use words for white, silver, gray (sic), black, red, maroon, yellow, olive, lime, green, aqua, teal, blue, navy, fuscia and purple. For any other colours, you should either use the hex code (for skyblue, it’s #87ceeb) or the RGB code (for sky blue, it’s rgb(135,206,235)).

Off Topic:

When you’re posting code, please could you wrap it in [ code ] tags, and take out all those extra blank lines so it’s easier for us to read.