Styles can be applied locally, in an internal style sheet, or as a seperate external style sheet.

When you create a style on either an internal or external style sheet, you can use the standard html tag like p for paragraph or img for image. You then follow the tag name with the properties and values enclosed in wiggly brackets{}. I prefer to give my html tags a class name if I think I will have more than one style of each tag. For example if I thought I might have several different styles of paragraphs, I might name them p.yellow, p.large, or even p.fred. It doesn't matter what the class name(after the .) as long as you use the right class name in the html portion also. So for example the style code for p.yellow might look like this:

p.yellow {background:yellow;width:500;color:blue;border:outset medium blue}

You simply list each property:value. Notice that a colon(:) is used instead of an equal sign as you would in standard html. Separate each property:value by a semi-colon(;). I applied the style I named "p.yellow" to the above line by using the tags <p class=yellow>I inserted my text here</p>. Look at my code by viewing source in your browser if you are confused.

There are 2 other tags that are commonly used with styles, the <div> and <span>. I again recommend using class names with each. So again it would be div.classname or span.classname. They do similar things. They take a section of your webpage and apply the style you define to that section. One way I have used these tags is to set off sections of a page with borders or different backgrounds. <div> will take a section of a page and apply the style to that entire section, including the empty space. <span> applies the style to the text only. Notice I added cyan and silver backgrounds to sections of this page using styles. The light blue(cyan) part used the <div> tag and the silver part the <span> tag. Notice the subtle difference. <div> works better to block out areas of a page. <span> generally works better for a few words of text. Both must have an end tag applied to them. These tags can be used in addition to other style tags. So, for example, you could take a whole section of a page that has a p style and an img style already in it and add the same border around the entire section.

Next>>
Index Basic Tags Links Design Layout Tables Image File Types Using Images Image Editing Lists Frames