CSS font style family color align, etc. H O W?

I’m pulling my hair our.

Too much information to sort out.

This isn’t working to well in CS4 which I have little understanding.

EVERYONE SAYS IT’S SO EASY. HA!

CSS File . . .

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>PWS_CSS</title>
</head>

<body>
{
background-color:#000000;
background-image: url(‘BambooTabu.jpg’); background-attachment: fixed;
}

NONE OF THIS BACKGROUND STUFF WORKS? :x

p {font-family: “Palatino Linotype”, “Book Antiqua”, Palatino, serif; font-size:12px; color:#099 (I don’t know what #099 means?) :sick:
{

h1,h2,h3,h4 {
font-family: “Palatino Linotype”, “Book Antiqua”, Palatino, serif: font-size:30px: font-color:cyan: text-shadow: 4px 4px 8px gray;
}

The different sizes h1 through h 4 work but no color or shadows?

</body>
</html>

Thanks - Rick

You can’t use CSS like that. CSS styles either need to go in a separate file that is linked to the page in the <head> of the page (preferable) or embedded in the head of the page inside <style> tags, like so:


<style type="text/css" media="all">
body {
background-color:#000000;
background-image: url('BambooTabu.jpg'); background-attachment: fixed;
}

p {font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size:12px; color:#099}

h1,h2,h3,h4 {font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif: font-size:30px: font-color:cyan: text-shadow: 4px 4px 8px gray;}
</style>

Then of course there needs to be some HTML between the <body> tags that these styles apply to. At the moment there isn’t anything there.

There are various ways to set a color. A simple way would be:


color: blue;

But there are not many words like that recognized in CSS. So another way is to use “hex” values, meaning 6 digits and/or letters preceded by a #.


color: #0000ff;

Each color has a hex value like that, and it allows for a lot of colors and shades. They work in groups of two, so if you have a color like blue that has three pairs like 0000ff, you can simplify it to 00f.

So 099 is properly #009999, which is a very dark blue color.

Ah, looking again at your code above, I maybe see the confusion. You don’t use all this stuff in a CSS file:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PWS_CSS</title>
</head>

<body>

</body>
</html>

That code is for an HTML file.

In a CSS file, you just place the actual CSS styles:

body {
background-color:#000000;
background-image: url('BambooTabu.jpg'); background-attachment: fixed;
}

p {font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size:12px; color:#099}

h1,h2,h3,h4 {font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif: font-size:30px: font-color:cyan: text-shadow: 4px 4px 8px gray;}

Then you save this as a text file ending in .css.

To clarify what ralph said, a rewrite. Basically you’re putting it in the wrong place. Style as a tag does NOT go in the BODY tag… (in fact it NEVER should). Likewise

Of course, is this a new page you’re working on, if so what’s with the Tranny doctype? Transitional is for old/outdated/half-assed 1997 style coding, not for building new websites.

So, what you are TRYING to do should go something 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"
	lang="en"
	xml:lang="en"
><head>

<meta
	http-equiv="Content-Type"
	content="text/html; charset=utf-8"
/>

<meta
	http-equiv="Content-Language"
	content="en"
/>

<title>
	PWS_CSS
</title>

<style type="text/css">
body {
	/*
		since P are content, you should NEVER declare them in PX, 
		much less an absurdly undersized 12px. I'd also NOT delcare that
		on P, but on BODY so all elements inherit.
	*/
	font:normal 100%/140% "Palatino Linotype","Book Antiqua",Palatino,serif;
	background:#000 url('BambooTabu.jpg') fixed;
	/* condensed property, faster to use just one line to say it */
}

p {
	color:#099; /* RGB in Hex */ 
}


h1,h2,h3,h4 { 
	/* family set on body, don't need to restate it now */
	/* 
		don't make them all the same size unless you REALLY mean it.
		IF you are going to change the size, change the line-height too 
		as it can't be trusted.
	*/
	/* there is no such attribute as font-color -- did you mean color? */
	color:#0FF: /* 0 red, 15 green, 15 blue == cyan */
	/* 
		text-shadow is not only annoyingly illegible in most cases,
		it's a CSS3 property meaning it has no business on a production site!
	*/
} 
</style>

</head><body>
	<h1>Site title</h1>
	<p>Some test content</p>
</body></html>

STYLE has to go inside a STYLE tag, or be LINKed from an extrernal file. For large amounts of static CSS like above, it would probably be better to move it all to it’s own file and link it in thus:


<link
	type="text/css"
	rel="stylesheet"
	href="screen.css"
	media="screen,projection,tv"
/>

the media part tells it those devices are what should receive that CSS – that way you aren’t wasting time sending color or fancy layout to print, or can make customized print/handheld/etc…

Ralph started to explain the color codes, but you were also confused by the three digit ones?

#00F == #0000FF == 100% blue
#804 == #880044 == Purplish-blue.

hexadecimal – each row is 0…15, with A-F representing 10 through 15. Red, green, blue – standard color mixing. If you’re not familiar with RGB… aka additive light:

red + blue == magenta
red + green == yellow
blue + green == cyan

Also, read the comments I put into that CSS – a lot of ‘issues’ there.

I understand the external style sheet and how it’s linked to an HTML page.

What goes on the VERY FIRST line in the style sheet?
The SECOND line . . . etc?

When do I start with the <body> tag in a CSS style sheet?

then . . . the order of.

backgroung-image:url etc .
p{ }
a{ }

text styles
font family
h1,h2,h3, etc.
margin-left:auto
margin-right:auto
max-width: 960px
navigation

What is the proper order of these items in a CSS stylesheet?

I can find examples off most of these items on the net but not the logical order and placement for them.

I know so little it’s dangerous :goof:

Thanks Rick

There is no proper order, you put them in however you want… Though <BODY> does not go in CSS as that’s not CSS, that’s HTML. Do you mean “body {}”?

I LIKE to keep them in the order of a reset, followed by any global tag settings, followed by the source order of the base template, followed by the stuff that’s unique to specific pages.

Some people like to group their attributes alphabetically, others (like myself) like to put them in by “category” – positioning, formatting, padding/margin, text properties then colors/background/borders in that order.

But really it’s up to you. Just remember that order DOES matter for “specificity” – which is to say later declarations will override previous ones.

Ok… clear your head there… lol

  1. all style-‘sheets’ rules must be stated within <style> tag
    or
  2. linked to an external file using <link href=“stylesheetURL” rel=“stylesheet” type=“text/css” media=“targetmedia…I recomen you use ALL”>

either way, <style> or <link> it must be WITHIN the <head> tag of your HTML doc and not within the <body> tag as you have it.

if you have an external(separate) stylesheet you DO NOT need to use <style> in THAT ( the external style sheet)file.

Thanks DEATHSHADOW60 (that name almost scare me)

This is my complete main.css stylesheet

{
background-color:#000000;
background-image: url(‘…/Images/Blinds1.png’); background-attachment: fixed;
}

{
margin-left:auto;
margin-right:auto;
max-width: 950px;
}

p {font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif; font-size:100%/140%; color:#CCC;
}

h1,h2,h3,h4 {font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif; font-size:100%/140%; color:#CCC;
}

Here is my link in the HTML page

<link type=“text/css” rel=“stylesheet” href=“src/main.css”>

Doesn’t work at all!

What about folder order?

Your first CSS statements aren’t going to do anything:

{
background-color:#000000;
background-image: url('../Images/Blinds1.png'); background-attachment: fixed;
}

{
margin-left:auto;
margin-right:auto;
max-width: 950px;
}

They have to apply to something: the body, a div class, something.

Do I rap them with body

how?

You’re not “wrapping” anything - that’s something you do in HTML, not in CSS. In CSS, you’re just telling the browser what style to apply to what objects. So, if you wanted your background-color and margins to apply to the entire body, you’d use:

body {
    background-color:#000000;
    background-image: url('../Images/Blinds1.png');
    background-attachment: fixed;
    margin-left:auto;
    margin-right:auto;
    max-width: 950px;
}

If you wanted them to apply only to the “something” div, it would be:

.something {
    background-color:#000000;
    background-image: url('../Images/Blinds1.png');
    background-attachment: fixed;
    margin-left:auto;
    margin-right:auto;
    max-width: 950px;
}

A single CSS rule (or ‘declaration’) has this basic structure:

h2 {color: red; background: blue;}

So, first you have an element selector. In the example above, it’s h2. The whole point of CSS is to choose HTML elements to style. (Some of the rules you posted had no element selector, such as

{
background-color:#000000;
background-image: url('../Images/Blinds1.png'); background-attachment: fixed;
}

… so those rules can’t apply to anything.)

After the element selector, you have a bunch of ‘declarations’, all of which are wrapped in { … }.

Each declaration cites a ‘property’ (e.g. ‘background’), followed by a colon and then a ‘value’, such as ‘blue’.

You can apply the rules to more than one element at a time like this:

h2, h3 {color: red; background: blue;}

Here, both h2s and h2s will receive those styles. (Note there’s no comma after the last item).

If you want to target only certain h2s, you have a few options. You could apply a class to the h2 (e.g. <h2 class=“special”>), and then target it like so:

h2.special {color: red; background: blue;}

Often a better way to target certain h2s would be to look at the container they are in. Say you want to target all the h2s in the #main div. Do it like so:

#main h2 {color: red; background: blue;}

Hopefully that all makes some kind of sense. :slight_smile:

That worked!

So now I set

p {
a {
h1,h2,h3 {

. . . etc . . ?

Okay I actually have it working now.

Thank you all very much.

Tomorrow I’ll be at it again.

It is easy, the same way the game Go is easy: an hour to learn, a lifetime to master. :slight_smile:

Deathshadow is correct that there’s no right or wrong way to order a stylesheet, but when you start doing them, you’ll find you do better by coming up with an order that makes sense to you. I’ll be a big dog and link to my own site, mostly because I put some time into finding out how people who code better than me organize their stylesheets. :slight_smile: I came up with an adaptation based on several sources, but you may want to do something different. Whatever works for you.

Order sometimes DOES matter within a particular selector, such as using shorthand in border properties:

border: 1px solid #000;
Off Topic:

Scary part is I’ve been using that name over the computer since I was logging onto a PDP-11 thirty years ago from my Trash-80 model 1… I’ve been deathshadow in one form or another on fidonet, genie, compuserve, and then the web…

<peter>yes, compuserve</peter>

Great when a nickname you chose when you were 12 sticks with you for 30 years. From 150 baud to 22mbps…

Compuserve. Genie. Prodigy. Wow. The Wild West days of the Internet. I remember them well, though I actually started on, uh, AOL. Sue me, I didn’t know any better.

NEW html page . . .

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Coto De Caza Real Estate</title>
</head>
<link rel=“stylesheet” type=“text/css” href=“chartpages.css” />
<body>
<h2> Coto de Caza Snapshot</h2>
<p>Thirteen year average sale price chart and a linear pricing chart for Coto de Caza</p>

<img src=“Images/12yr_cdc_det.jpg” width=“920” height=“698” alt=“CDC-Detached” />
<img src=“Images/12yr_cdc_att.jpg” width=“920” height=“698” alt=“CDC attached” />

THESE jpeg’s do not align between the margins as instructed in the css page below?

</body>
</html>

New CSS Page

chartpages.css

body {
background-color:#000000;
background-image: url(‘…/Images/Blinds1.png’));
background-attachment: fixed;
margin-left:20%;
margin-right:20%;
max-width: 960px;
}

p {font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif; color:#FFF; text-align:left; font-size:1em;}

h1,h2,h3,h4 {font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif; color: #F1D32E; text-align:center;} DOES NOT ALIGN CENTER!

text-align:center centers the text within the width of the block containing it. It only centers text and only within the width of the block containing it.

In your case since you have set max-width:960px on the body the web content will never go wider than that and will remain to the left when the browser window is wider with the text centered within that 960px width.

I have a .pdf file attached depicting what I’m thinking for my web site design.

Each one of these pages could have 4 charts max but mostly three.

Page width is 960px.

I would like all of the display, positioning, style, etc., to be in the css file.

This seems pretty basic. How is it that it’s is so difficult to understand?

Thanks. Rick