css code help

biferi

Daemon Poster
Messages
690
I am trying to pickup css and I don't know if I understand it.

If I want my background color on the web pake to be say black I would type this.

[BODY]
BACKGROUND-# and then type the hax number right?????
 
The above syntax is correct - I'm not sure where you picked up what you had originally, but it most definitely isn't valid CSS!
 
If I use just HTML to place a photo on my page it goes like this
<img src="photo.jpg" width="595" alt="" border="0">

Now because I always keep my HTML file and photos in the same Directpry on my server I never have to put the location of were the photo is.

I can get away with just typeing the name of my photo and that is all and the browsers find it.

Now is this a flook or can I do this wen I ad a photo with css
 
Yes, if the photo is in the same folder as your HTML file you do not need to specify the location.

if the photo is named photo.jpg do this I like to place a closing tag in my <img> tags
<img src="photo.jpg" border="0" />

make sure your photo is a jpg and named "photo.jpg"

The width and height attributes, just help the web page render faster. It allows the browser to set aside room for the image before it is actually downloaded. ( don't use one with out the other.)

The alt attribute is for accessibility for blind people, or people who use screen readers etc. (if your not gonna type anything in between the "" then take it out)

the border="0" removes the default border around the image.
 
Can anyone help me with understanding one thing about css?

I know you can use the <div> </div> tags and wen you ad things like
<div stile=" "> </div>

You can put diferant commands in the Qaotes.

Then I just saw how you can put all the stile commands in the header and use some kind of referance comand.

So anything that should be doen in the div tag gets re directed to the commands in the header tags.

WHY???????

Why can't you just say place a background image to your page in the <div> tag in the body of the page.

And some people put the background image <div> in the header WHY?????
 
I know its difficult at first once you learn it, you got it.

All your answer are probably here http://www.w3schools.com/

You have three ways to implement CSS

1. Inline
These are CSS elements that are placed Inline with the <div> normally contained in a <span> tag. Use this method to apply one style to one element on one page

2. Embedded
This is when you use the <style> tags in the header portion of your HTML. Use this style to apply styles to multiple elements on one page.

3. External
This is CSS elements contained in an external document with a .css extention. Use this method to apply several styles to multiple elements on multiple pages
(this method is what makes CSS so powerful)

Now if you have two different css styles trying to apply to the same element on a web page the priority is the same as I have listed above. A browser will apply the embedded style first if none exist it will apply the external.


Edit: The external .css is linked to your HTML file with a <link /> tag
 
So if I use the <H1> </H1>
to type my headline

and around this I use the <div> tags to center it and move it down a pit and all of this is not in the HEAD tags I am ok doing it?????

And then a little bit down the page I ad another <div> tag to do something to say a photo I put on the page and this also is not in the Header Tag I will be ok????

I thought they were telling me that you must put things in the header????????????????????
 
So anything that should be doen in the div tag gets re directed to the commands in the header tags.

WHY???????
See, this is the sort of question I don't mind answering, because you've clearly gone away, thought about things and attempted them first. It's a fairly basic question - but a perfectly valid one.

The big answer to "why" is that CSS aims to separate style and content. It's not always been used that way as it's been abused heavily over the years, but now things are settling down that's definitely the way it SHOULD be used. If you deal with all your style information in the header, or better yet a separate file, you don't need to touch your content if you want to change the style around. So say you marked up all important paragraphs with a class="ip" marker. And say they were all red at present, but you wanted to make them blue, with a green background (NEVER do those colours in real life, it's just an example!)

If you're using the old method of font tags or even embedding CSS into each element, you've got to go through and manually change each "important" paragraph in your document. Got 1? Not to much of a hassle. Got 5? Achievable. Got 100? 5000? On large websites, this wouldn't be unrealistic - and changing that lot all by hand wouldn't be fun.

Using external / embedded CSS, you just make one change - you specify the colour for everything using the "ip" class, and it all changes over like that. Much better for maintainability, and much better for design. There's a lot of other arguments for it, but that's one of the main ones.
 
Okay.....

Lets back up a little. You have actually been talking about 2 different things here.

<div> tags are not css they are in a language called XHTML which is a language that combines HTML with another language called XML

<h1> tags are basic HTML

Think of css as more like decorating your XHTML.

The XHTML is this
<body>
<div>
<h1>XHTML is COOL!</h1>
</div>
</body>
That will just display that text in Heading 1


CSS decorates it Lets make the text in the body a different color. Make sure its placed in the Header
<head>
<style type="text/css">
body {color: #33ffcc;
}
</style>
</head>
 
Back
Top Bottom