Taking Shortcuts with Internal Style Sheets

Sun, Mar 22, 2009

Tech Tips

As simple as it is, I can never remember the syntax for defining a block of css within html. It is of course better practice to put your css in a seperate file and reference it. However, here is sample snippet to define internal style(s):

  1. <style type="text/css">
  2. body {color: blue}
  3. a {color: blue; font-weight:bold;}
  4. #id_comment {width: 100px;}
  5. </style>

And if you change your mind, here is a sample with the css in its own file:

  1. <link rel="stylesheet" type="text/css" href="thestyle.css" />
  2. </head>

Here is a css reference.

Why are Internal Style Sheets helpful?
If you are a developer and you like taking shortcuts. Your html designer is not going to approve, but just tell him that it's a beta.
Speaking on which, It's also good for testing. Most recently, I was using a third party Django comments module that had some style that I wanted adjusted. Instead of hunting down the source, the quick test was to define the needed style adjustments right before the tag.

Bookmark and Share

Comments are closed.