Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mfogel2002

macrumors newbie
Original poster
Jul 3, 2004
13
0
I just started to learn HTML. After doing a little reading about web design I found out that CSS is the way to go for setting up the style for a web page.

I am a little confused about CSS. Can I use CSS along with HTML? For example I am using Taco as my HTML editor. Would I just use the CSS style commands throughout my HTML code? Or do I need to scrap the HTML and only use CSS?

Sorry for the newb question, I am just a little confused if CSS is different from HTML or if it just works with it.
 
CSS can either be embedded in your html or you can reference an external .css file or you can put in the head or you can mix and match, it's very flexible.

for example lets colour some text using the style css attribute

Code:
<div style="color:red;">some text<div>

the style attribute can be applied to almost any html tag

The real benefit of css is the ability to apply the same style to lots of different things.

create a file with a .css extension and add the following

Code:
.mystyle
{
    color: red;
}

then change your html to

Code:
<div class="mystyle">some text<div>

and add the following to your head section

Code:
<link rel="stylesheet" type="text/css" href="filename.css">

you can also change the style of all tags of a certain type, the following code added to your css file will change the style of a table cells.

Code:
td
{
    color: red;
}

These are the basics, but you can do so much more with CSS, you should have a search for a good guide on the internet (there are lots).
 
No problem.

I just noticed that I missed out the / in the closing div tags in the example code, I'm sure that you spotted that though ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.