Inserting CSS

You can Insert CSS into your HTML document in three simple ways:

  • External stylesheet
  • Internal stylesheet
  • Inline styling

Let’s begin with the cleanest way, the external stylesheet. This is done using a CSS file, the usual file extension for this is .css, but any plain text file works. The most common way of inserting from an external stylesheet is with the HTML link element:
<link href="stylesheet.css" rel="stylesheet" type="text/css" />

An internal stylesheet is simply putting your CSS inside the HTML document, usually within <head>. Let’s see the exmaple:
<style type="text/css">
/* Your CSS here */
h1{ color:red; }
</style>

Inline styling is very simple to do, but if used too foten can make your documents overly complex, and defeats the point of CSS, you should try and avoid inline styling wherever you can. Here’s an example of it:
<h1 style="color:red;">CSS is a good thing!</h1>

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MSN Reporter
  • MySpace
  • PDF
  • Ping.fm
  • Posterous
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
This entry was posted on Thursday, January 14th, 2010 at 11:30 pm and is filed under CSS Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Post a Comment