Bytes Tech Community, We heart tech!

Register Now


2 Pages  1 2 > 
Reply to this topicStart new topicStart Poll

Outline · [ Standard ] · Linear+

 CSS For Beginners

Gareth
post Jun 28 2005, 10:41 AM
Post #1


Mr. Bling Bling :P
Group Icon

Group: Members
Posts: 7,555
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 10,736
------------------
Member No.: 1

Reputation: 184 pts




CSS is short for 'Cascading Style Sheets', and is a part of current web standards. You can control most apects of your website design from one CSS sheet. Lets begin,

Basics

CODE
body{ background-color:#000000; }


This controls the background color of your website, you should change '#000000' to the color that you want the background of your website to be.

Classes

If you want to define unique sets of attributes for seperate parts of your site then you will have to make use of classes. These are defined as follows:

CODE
.bigfont{ font-family:Arial, Helvetica, sans-serif; font-size:30px; }


- The '.' tells us that this is a new class, you can change the fonts and sizes to your liking, now in your html file if you use the code below then your text will have the attributes that you defined in the CSS sheet:

CODE
<font class="bigfont">This text will have the attributes defined in the css sheet.</font>


ID's

IDs work in similar ways to classes, except that they can only be used once (whereas classes can be used multiple times), so only use IDs for unique properties. ID's are mainly used to incorporate Style Sheet models into JavaScript or DHTML, here's an example of how to use ID's:

CODE
#bigfont{ font-family:Arial, Helvetica, sans-serif; font-size:40px; }


Now in your html file you would use:

CODE
<font id="bigfont">This is big text.</font>


Note we now use 'font id' instead of 'font class'.

Linking to External CSS

Once you have your CSS Sheet made, you will want to encorporate it into your website, to do this place the code below within your 'head' tags:

CODE
<link rel="stylesheet" type="text/css" href="sheet.css" media="all" title="Your Title" />


You should swap 'sheet.css' with the name of your CSS Sheet, and also swap 'Your Title' with your own title.

Well, thats all the basics covered, enjoy.


User is offlineProfile CardPM
+Quote PostGo to the top of the page
WinSrev
post Jun 28 2005, 03:00 PM
Post #2


CodedFx Legend!
Group Icon

Group: Coders
Posts: 1,420
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 9,260
------------------
Member No.: 2

Reputation: 31 pts




font is also the same as span:
CODE
<span class="bigfont">This text will have the attributes defined in the css sheet.</span>

To make your css look neater i would probalise use this setup:
CODE
.bigfont  {
    font-family:Arial, Helvetica, sans-serif;
    font-size:30px;
}


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Gareth
post Jun 28 2005, 03:03 PM
Post #3


Mr. Bling Bling :P
Group Icon

Group: Members
Posts: 7,555
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 10,736
------------------
Member No.: 1

Reputation: 184 pts




Ok, thanks for the extra info.....i'm still relatively new to css aswell :)


User is offlineProfile CardPM
+Quote PostGo to the top of the page
skandalouz
post Jul 8 2005, 10:20 PM
Post #4


Loyal Member
Group Icon

Group: Members
Posts: 496
Gender: Not Telling
Sotw Wins: 2
------------------
Donate CFX Creds
CFX Credits: 419
------------------
Member No.: 70

Reputation: 41 pts




nice, but i think i will stick to plain html for now, i mean most of the stuff i can do in html, and the only advantage i know of is using one file for multiple pages


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Gareth
post Jul 8 2005, 10:51 PM
Post #5


Mr. Bling Bling :P
Group Icon

Group: Members
Posts: 7,555
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 10,736
------------------
Member No.: 1

Reputation: 184 pts




QUOTE(skandalouz @ Jul 8 2005, 11:20 PM)
and the only advantage i know of is using one file for multiple pages
*



But that is a very big advantage.


User is offlineProfile CardPM
+Quote PostGo to the top of the page
RockyNguyen
post Aug 5 2005, 02:13 PM
Post #6


Newbie
Group Icon

Group: Members
Posts: 7
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 7
------------------
Member No.: 754

Reputation: none




That was a pretty good tutorial. Thanks because I didn't know much CSS until I read this.


User is offlineProfile CardPM
+Quote PostGo to the top of the page
freelancer
post Sep 24 2005, 04:52 AM
Post #7


Newbie
Group Icon

Group: Members
Posts: 2
Gender: Not Telling
------------------
Donate CFX Creds
CFX Credits: 2
------------------
Member No.: 255

Reputation: none





Nice helpful tutorial :D


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Simon
post Dec 16 2005, 04:58 PM
Post #8


Member
Group Icon

Group: Members
Posts: 42
------------------
Donate CFX Creds
CFX Credits: 42
------------------
Member No.: 2,049

Reputation: 1 pts




QUOTE(skandalouz @ Jul 8 2005, 11:20 PM)
the only advantage i know of is using one file for multiple pages
*


(With a little PHP) I think it is possible for a user to select between different CSS Stylesheets, giving them more control as to how they view your site. This can be as simple as larger fonts for those who cant see well or a completly different colour scheme.

Also, I remember reading somewhere that there was a tag like this:
CODE
p {color: #000000 !important;}

Where the "!important" part will set the attributes set in those particular {} brackets will not be overridden by a subsequent rule. Which can always be pretty handy.


User is offlineProfile CardPM
+Quote PostGo to the top of the page
DoubleJ
post Dec 18 2005, 12:44 AM
Post #9


i might be a coder.... i think...
Group Icon

Group: VIP Members
Posts: 339
Gender: Not Telling
------------------
Donate CFX Creds
CFX Credits: 13,508
------------------
Member No.: 856

Reputation: 14 pts




QUOTE(Simon @ Dec 16 2005, 06:58 PM)
(With a little PHP) I think it is possible for a user to select between different CSS Stylesheets, giving them more control as to how they view your site. This can be as simple as larger fonts for those who cant see well or a completly different colour scheme.

Also, I remember reading somewhere that there was a tag like this:
CODE
p {color: #000000 !important;}

Where the "!important" part will set the attributes set in those particular {} brackets will not be overridden by a subsequent rule. Which can always be pretty handy.
*



There is a javascript based styleswitcher that enables you to let a user switch between different preset stylesheets for one page.

And depending on the way you coded your site and used styling(like NO tables for the layout) can make your stylesheets show extremely different websites while content remains the same.

I had a styleswitcher on my site once to but at version 3 I got it of my site.
Maybe I will return it when I add more styles to my site, but for now here is the article about the switcher:
http://www.alistapart.com/articles/n4switch/

and if you want to see what CSS can really do you should certainly give:
http://www.csszengarden.com
a try.


User is offlineProfile CardPM
+Quote PostGo to the top of the page
RiplasH
post May 6 2006, 07:20 AM
Post #10


Member
Group Icon

Group: Members
Posts: 36
------------------
Donate CFX Creds
CFX Credits: 36
------------------
Member No.: 4,201

Reputation: 8 pts




CSS...

Never really knew hat it even stood for.

so thanks. this helped ^_^


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Tom
post Dec 10 2006, 07:09 PM
Post #11


Dedicated Member
Group Icon

Group: Members
Posts: 842
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 1,272
------------------
Member No.: 5,944

Reputation: 10 pts




Just a 'lil error: under the topic "Linking to an external Stylesheet, you missed a space beween the: " and the / at the end.

Should be " />


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Gareth
post Dec 10 2006, 07:53 PM
Post #12


Mr. Bling Bling :P
Group Icon

Group: Members
Posts: 7,555
Gender: Male
------------------
Donate CFX Creds
CFX Credits: 10,736
------------------
Member No.: 1

Reputation: 184 pts




QUOTE(Tommeh @ Dec 10 2006, 08:09 PM)
Just a 'lil error: under the topic "Linking to an external Stylesheet, you missed a space beween the: " and the / at the end.

Should be " />
*


Of course, fixed and thank you :)


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Pistol
post Dec 19 2006, 05:17 AM
Post #13


Advanced Member
Group Icon

Group: Members
Posts: 57
------------------
Donate CFX Creds
CFX Credits: 38
------------------
Member No.: 259

Reputation: none




How do you put an image url instead of a background color (Seems more simple to make a CSS Whit simply making the image in PS, add text in PS then Make a CSS and add the rest :)


User is offlineProfile CardPM
+Quote PostGo to the top of the page
That Negative Guy
post Dec 19 2006, 10:55 PM
Post #14


Dedicated Member
Group Icon

Group: Members
Posts: 903
Gender: Not Telling
------------------
Donate CFX Creds
CFX Credits: 6,824
------------------
Member No.: 3,091

Reputation: 105 pts




QUOTE(Pistol @ Dec 18 2006, 09:17 PM)
How do you put an image url instead of a background color (Seems more simple to make a CSS Whit simply making the image in PS, add text in PS then Make a CSS and add the rest :)
*



CODE
.class {
   background: url('path/to/image.jpg');
}


User is offlineProfile CardPM
+Quote PostGo to the top of the page
Pistol
post Dec 20 2006, 02:10 AM
Post #15


Advanced Member
Group Icon

Group: Members
Posts: 57
------------------
Donate CFX Creds
CFX Credits: 38
------------------
Member No.: 259

Reputation: none




thank you very much :)


User is offlineProfile CardPM
+Quote PostGo to the top of the page

2 Pages  1 2 >
Reply to this topicTopic OptionsStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: