Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
alabama Mini-CSS tutorial 3 - The 3 different Style Sheets
#1
1. External Style Sheets

Using external style sheets instead of internal or inline style sheets will keep your HTML page very clean.
I recommend everyone uses external in all of their work.

It allows you to change the whole website's appearance just by changing one file. Each page that you want the style on must contain the <link> tag inside of the heading.

Example:

PHP Code:
<head>
<
link rel="stylesheet" type="text/css" href="style.css" />
</
head

In order for the above to work, you need an actual style.css file.

in the file you put content similar to this:

PHP Code:
body {background#333333;color: #ccc;text-align: center;line-height: 1.4;font-family: Verdana, Arial, Sans-Serif;font-size: 13px;font-style: none;} 

The above is the actual background for Hackforums, minus the bg.png.

Then we would but this in the HTML doc

PHP Code:
<body>This text will be centered and be a purple-ish color.</body



2. Internal/Inline Style Sheets

Internal or Inline style sheets should only be used when you want a certain page to have a certain design.

The page containing internal style sheets must be within the <head> tags and use the style tags.

Example:

PHP Code:
<head>
<
style type="text/css">
body {
      
background#333333;
      
color#ccc;
      
text-aligncenter;
      
line-height1.4;
      
font-familyVerdanaArialSans-Serif;
      
font-size13px;
      
font-stylenone;
}
</
style>
</
head

Inline style sheets can also be used like this:

PHP Code:
<p style="color:#873348;text-align: center;">This text will be centered and be a purple-ish color.</p

OR

PHP Code:
<body>This text will be centered and be a purple-ish color.</body



3. Multiple Style Sheets

Multiple style sheets can cascade into one.
I don't recommend using these unless you have an abnormally sized CSS file.

Let's do an example of using Multiple SS's

style1.css contents
Quote:body {
color: #873348;
}

style2.css contents
Quote:body {
text-align: center;
}

Then in the HTML doc, you would need this in the head tags:
Quote:<html>
<head>
<link rel="stylesheet" type="text/css" href="style1.css">
<link rel="stylesheet" type="text/css" href="style2.css">
</head>

<body>
This text will be centered and be a purple-ish color.
</body>

Using that would make your body's style the same as

PHP Code:
<p style="color:#873348;text-align: center;">This text will be centered and be a purple-ish color.</p

OR

PHP Code:
<style type="text/css">
body {
color:#873348;
text-aligncenter;
}
</
style



Ending

Thanks for reading my tutorial on the different types of Cascading Style Sheets.
Constructive criticism on my work is appreciated.

[Image: 2.png]
Reply
#2
Great tutorial! Don't see many CSS tutorials todays!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Free Worker HTML, CSS, Javascript ImFocuzz 2 1,289 04-05-2014, 10:01 PM
Last Post: VHPanda
  Forum CSS code problem. inferno.lion 0 830 06-10-2013, 02:48 AM
Last Post: inferno.lion
  MyBB CSS Postbit Buttons Peter L 1 1,459 07-14-2012, 05:52 PM
Last Post: 'Snorlax
  inline css question andrewjs18 1 1,022 03-24-2012, 10:11 AM
Last Post: Haxalot
  Need a CSS Teacher! ImFocuzz 2 1,098 03-08-2012, 06:01 PM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)