0 members and 662 guests
No Members online

» Site Navigation
» Stats
Members: 35,442
Threads: 103,075
Posts: 826,688
Top Poster: cc.RadillacVIII (7,429)
|
-
In this tutorial you will hopefully learn:
>>What CSS is
>>Why CSS is so useful
>>How to code CSS and which part does what
>>How to code CSS into your HTML (XHTML) Document
CSS stands for Cascading Style Sheets, it can and from my point of view should be used in most HTML or XHTML documents.
First of all, some people may be thinking why they should use CSS when they could just use some font tags?
Well CSS can speed up the loadind of your web pages because the CSS file can be placed in an external location, which will be called up just once and then cached (stored) on the user's computer so it does not need to be loading everytime somebody views your page. With CSS you can also position anything you want EXCATLY where you want it on the page, pixel perfect 
CSS also saves coding, for example:
Code:
<font size="12px" color="#333333"> Texty McTextus </font>
<font size="9px" color="#cccccc"> Texty McTextus With a hint of more text </font>
<font size "12px" color="#333333"> Texty McTextus with some text </font>
This could be cleaned up by using CSS:
The CSS
Code:
.maintext {
font-color:#333333;
font-size:12px;
}
.subtext {
font-color:#cccccc;
font-size:9px;
}
The HTML
Code:
<p class="maintext">Texy McTestus </p>
<p class="subtext"> Texty McTextus With a hint of more text**</p>
<p class="maintext"> Texty McTextus with some text </p>
Right lets break all this down...
Lets look at the CSS, here I will show you what each part does.
.maintext { this gives the class a name, it is a class in this case because it has a dot (.) at the beginning. (I will go through classes, ID's and Tags later.) The '{' ends the list of classes,IDs or Tags.
font-color:#333333; This is as simple as it looks, font-color is telling what to modify, and the ':' is the beginning of the information and #333333 is what the modification is, ending with a ; to end the information.
font-size:12px; You should be able to guess this by now using the example above.
} This ends the 'maintext' class.
See if you can work out the 'subtext' class on your own 
The HTML is very simple,
<p class="maintext">Texy McTestus </p> <p opens the paragraph tag, class= is stating which class (CSS Class) to use and '"maintext"' is the class to use. Don't forget the speech marks on the class!
See how simple it is?
Because I am a fan of the more simple designs with more code than images I always use divs and CSS instead of tables, I use Divs instead for many reasons:
* Browsers read through tables twice before displaying their contents, once to work out their structure and once to determine their content
* Tables appear on the screen all in one go - no part of the table will appear until the entire table is downloaded and rendered
* Tables encourage the use of spacer images to aid with positioning
* CSS generally requires less code than cumbersome tables
* All code to do with the layout can be placed in an external CSS document, which will be called up just once and then cached (stored) on the user's computer; table layout, stored in each HTML document, must be loaded up each time a new page downloads
* With CSS you can control the order items download on to the screen - make the content appear before slow-loading images and your site users will definitely appreciate it.
Why should you use divs and not tables? Well first of all your code will be much cleaner, <div id=#idhere"> </div> is much tidier than loads of table tags and padding etc. you can also change complete sites without touching the html, just by modifying the CSS, a great example of this is CSSZenGarden. They have created some amazing layouts without touching the HTML.
Tables existed in HTML for one reason: To display tabular data. But then border="0" made it possible for designers to have a grid upon which to lay out images and text. Still the most dominant means of designing visually rich Web sites, the use of tables is now actually interfering with building a better, more accessible, flexible, and functional Web.
The main problems with using tables is:
* mixes presentational data in with your content.
* This makes the file sizes of your pages unnecessarily large, as users must download this presentational data for each page they visit.
* Bandwidth ain't free.
* This makes redesigns of existing sites and content extremely labor intensive (and expensive).
* It also makes it extremely hard (and expensive) to maintain visual consistency throughout a site.
* Table-based pages are also much less accessible to users with disabilities and viewers using cell phones and PDAs to access the Web.
Here comes the trickest bit, still, this is not tricky...
There are 3 different rules you can apply, you can apply a:
>>Class (can apply to any tag)
>>Tag (which changes the look of that tag (everytime it is used ) )
>>ID's + pseudos (I just use ID)
Lets go into more detail; you need to know where to use each type of rule. This depends on your coding style, this is mine, it may be similar to yours or completely different.
I use classes for things such as text, ID's and Tags do not work with text so im forced to use a class.
I use a Tag rule when i want a rule to apply to only a certain tag, for example if i wanted every image's border to be removed i would create this CSS in the header:
img {
border:0;
}
So every image (in an img tag) would have its border removed, this is useful because you onyl need to create the rule and its done, you do not need to apply that to any tags etc.
I mainly use ID's when styling Divs, Not really sure why. Its the way I learnt it and i have never tried classes.
Now you know how to write CSS and apply it to tags go and practice it untill i have finished the full website tutorial
I will update this when its done 
And note, i have been doing this for about a week (03/04/2006) and i know all this. That is how simple it is.
hope you learnt something,
xXx--Ben--xXx
Note: Please do not Rip this tutorial, if you wish to use it or any part of it please ask me and then I will give you permission.
-
You could have actually used span's instead of p tags. Since a p tag will also add spacing because it's a new paragraph.
Also, you put class=".maintag" it should just be class="maintag". the peroid is for specifying it as a CLASS in the CSS part of the code.
Looks good. Good way to get started with CSS if you haven't used it before.
Resident father figure.
-
Thanks for telling about that 
Why i still use DW otherwise i would make these crappy errors.
-
<div class='quotetop'>QUOTE(Project_Number_10 @ Apr 4 2006, 11:56 AM) [snapback]163800[/snapback]</div>
Thanks for telling about that 
Why i still use DW otherwise i would make these crappy errors.
[/b]
lol, don't blame DW. I use DW too. just codeview only.
Resident father figure.
-
I didnt blame DW Lol :P
I mean thats why I use DW, if I did not I would make so many errors but with DW I don't make them
-
Nice sharing on HTML&css basics.
-
Ditch Dreamweaver and use Notepad++. <3

"I'm just a notch in your bedpost, but you're just a line in a song "
-
To create a website HTML and CSS in combination plays a very important role in designing a website...CSS will help in creating a website code which can be edited easily in future within minutes if there is any designing issues like changing color of website or image or any issue related to hyperlink...
-
-
This is very helpfully for me to learn HTML and CSS. Thanks.
Similar Threads
-
By robgasm in forum Other Tutorials
Replies: 6
Last Post: 11-18-2009, 10:25 AM
-
By Spekta in forum Other Tutorials
Replies: 16
Last Post: 10-28-2008, 03:17 AM
-
By Punk in forum Other Tutorials
Replies: 22
Last Post: 06-09-2006, 08:26 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|