Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-13-2010, 06:18 PM   #1
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default css code help

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?????
__________________

biferi is offline   Reply With Quote
Old 03-13-2010, 07:04 PM   #2
In Runtime
 
Disenchanterx's Avatar
 
Join Date: Mar 2010
Posts: 164
Default Re: css code help

Are you using inline or embedded

body {background-color: #000000;
}
__________________

__________________
M.C.S.E.
Minesweeper Consultant / Solitaire Expert
Disenchanterx is offline   Reply With Quote
Old 03-14-2010, 01:20 PM   #3
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: css code help

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!
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 03-14-2010, 01:56 PM   #4
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: css code help

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
biferi is offline   Reply With Quote
Old 03-14-2010, 06:05 PM   #5
In Runtime
 
Disenchanterx's Avatar
 
Join Date: Mar 2010
Posts: 164
Default Re: css code help

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.
__________________
M.C.S.E.
Minesweeper Consultant / Solitaire Expert
Disenchanterx is offline   Reply With Quote
Old 03-14-2010, 06:56 PM   #6
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: css code help

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?????
biferi is offline   Reply With Quote
Old 03-14-2010, 07:26 PM   #7
In Runtime
 
Disenchanterx's Avatar
 
Join Date: Mar 2010
Posts: 164
Default Re: css code help

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
__________________
M.C.S.E.
Minesweeper Consultant / Solitaire Expert
Disenchanterx is offline   Reply With Quote
Old 03-14-2010, 07:41 PM   #8
Daemon Poster
 
Join Date: May 2009
Posts: 690
Default Re: css code help

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????????????????????
biferi is offline   Reply With Quote
Old 03-14-2010, 07:44 PM   #9
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: css code help

Quote:
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.
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 03-14-2010, 07:55 PM   #10
In Runtime
 
Disenchanterx's Avatar
 
Join Date: Mar 2010
Posts: 164
Default Re: css code help

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>
__________________

__________________
M.C.S.E.
Minesweeper Consultant / Solitaire Expert
Disenchanterx is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 12:54 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0