|
|||||||
| Register | FAQ | Rules | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
AN INTRODUCTION TO CASCADING STYLE SHEETS
CSS is the abbreviation of: ‘Cascading Style Sheets’. CSS is an extension to basic HTML that allows you to style your web pages. An example of a style change would be to make words bold. In standard HTML you would use the <b> tag like so: Code:
<b>make me bold</b> Another disadvantage can be found in this example: say you wanted to make the above text bold, make the font style Verdanna and change its color to red, you would need a lot of code wrapped around the text: Code:
<font color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif"><strong>This is text</strong></font> Code:
<p class="myNewStyle">My CSS styled text</p> Code:
<style type="text/css">
<!--
.myNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}
-->
</style>
Besides the fact that you will be cluttering up your pages with the same CSS code, you also find yourself having to edit each of these pages if you want to make a style change. Like with JavaScript, you can define/create your CSS styles in a separate file and then link it to the page you want to apply the code to: Code:
<link href="myFirstStyleSheet.css" rel="stylesheet" type="text/css"> HOW TO CREATE A LINKED EXTERNAL STYLE SHEET To create an external style sheet all you need to do is create a simple text document (on windows you simply right-click and select new -> text document) and then change the file from type .txt to .css. You can change the file type by just changing the files' extension. The files' extension on windows tells the computer what kind of file it is and allows the computer to determine how to handle the file when for example you try to open it. You probably guessed it; CSS files are just specially formatted text files, and much in the same way HTML pages are. There is nothing special or different in the file itself, rather it is the contents of the file that make an HTML document and a CSS page what they are. When working with a external CSS document, there are a couple of points to remember: 1. You don’t add these tags in the CSS page itself as you would if you embedded the CSS code in your HTML: Code:
<style type="text/css"> </style> Code:
.myNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}
.my2ndNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}
.my3rdNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12pt;
color: #FF0000;
}
Code:
<p class="myNewStyle">My CSS styled text</p> Code:
<h2 class=”my3rdNewStyle”>My CSS styled text</h2> When you apply a CSS class to it, the CSS code overrides the default size that you would normally get with an <h2> tag in favor of the size specified in the CSS class. So now you can see that CSS can override default HTML tag behavior! In the above examples, I have CSS code where I define my CSS classes and then ‘apply’ them to various elements in the page. Another way to apply CSS is to globally redefine an HTML tag to look a certain way: Code:
h1 { font-family: Garamond, "Times New Roman", serif; font-size: 200%; }
What this CSS code does is set the font style and size of all <h1> tags in one shot. Now you don’t have to apply a CSS class as we did before to any <h1> tags since they are automatically all affected by the CSS style rules. Here is another example of where I give the whole page bigger margins: Code:
body { margin-left: 15%; margin-right: 15%; }
Code:
div {
background: rgb(204,204,255);
padding: 0.5em;
border: 1px solid #000000;
}
A few things to explain about the above: Color in CSS can be expressed in a few ways:
I typically use hex color since I am familiar with them or I just use named colors. So the last example can be rewritten like so: Code:
div {
background: green;
padding: 0.5em;
border: 1px solid #FF0000;
}
By using RGB (RGB is the acronym for: ‘Red Green Blue’) and Hex color, you can really get the exact color you want easily when you know your codes. Luckily many programs (like Dreamweaver) provide easy to use color pickers for you so you don’t need to know the values for the code. In this last example I will show you the ‘super cool’ CSS code that allows you to create link roll-over affects without images: Code:
a:link { color: rgb(0, 0, 153) }
a:visited { color: rgb(153, 0, 153) }
a:hover { color: rgb(0, 96, 255) }
a:active { color: rgb(255, 0, 102) }
Code:
"link-visited-hover-active", CSS is very powerful and allows you to do things that you can’t do with standard HTML. It is supported nicely now in all the modern browsers and is a must learn tool for web designers. The above examples are just a small sample of what you can do with CSS, but it should be more than enough for you to start styling your pages nicely. Like with many technologies CSS has a lot of capability that most people will not need to use often, if at all. So don’t get caught in the trap of thinking that if there is some functionality/feature available that you have to use it. Hello friends, its the first step. i will carry on this step by step. Thanks
__________________
GamesVenture |
| Sponsored Links |
|
|
|
#2
|
|||
|
|||
|
Wow! It's an excellent tutorial. Much helpful for the beginers.
![]() |
|
#3
|
|||
|
|||
|
thanks for ur help. can u provide me more link from them i can access more knowledge about it.
__________________
web design company |
|
#4
|
||||
|
||||
|
Great tutorial! Im still learning CSS the basic stuff, but i don't have much time. This will sure help out many people. Thanks for posting.
__________________
SEO Services & eMarketing Consultant Online Workforce Training "Enhance Online Business with iGuides Webmasters and Business Talk"
|
|
#5
|
|||
|
|||
|
Quote:
![]() Anyway, but you can try more tutorials on CSS in W3Schools Online Web Tutorials Tizag Tutorials Thanks
__________________
GamesVenture |
|
#6
|
||||
|
||||
|
Thanks Al-Zabir for very well explained tutorial and reference links. I hope it will help everyone learning CSS basics and we are looking forward to view your Step 2 tutorial anxiously
![]()
__________________
"Enhance Online Business with iGuides Webmasters and Business Talk" |
|
#7
|
|||
|
|||
|
Wow easy to follow steps.. Thanks for the tutorials hope to hear from you soon. Keep up the good work. Thanks
__________________
Free Wordpress Themes |
|
#8
|
|||
|
|||
|
Thanks for sharing information about CSS, but I want to know about advanced CSS. Please tell me if there are any sites regarding CSS.
|
| Sponsored Links |
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT. The time now is 08:15 AM.











Linear Mode
