Page Specific Stylesheets

The second way of using stylesheets is to add them into the head section of your web page.

If we use this method then the styles that we define can be automatically applied to every tag of the same type within the entire page. Later tutorials will demonstrate how to limit the effect to specified tags.

As an example, let's say that we want to make all of the list content on our page appear in red. We can do this using the following code:

<style type="text/css">
li {color:red;}
</style>

The page content will then appear like this:

  1. first entry
  2. second entry

As you can see from the above, we have also learned a little about how to define which tag the style command is to apply to. In each case the tag name appears at the start of the line and the style attributes for that tag are enclosed in braces {}. We can even set the same style to apply to multiple tags by separating the tag names with commas like this:

li, td {color:red;}

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate