Tangled web



Sunday, August 31, 2003

Style sheets
 
Styles may be declared in external linked style sheets, internalstyle sheets in the HEAD section of a page, or in line inside anHTML element. See The W3C Web Consortium site for much more detailed informaton. Or, go to the W3schools (unrelated to W3C) CSS pages for some good introductory material.
External style sheet

<link rel="STYLESHEET" type="text/css" href="monk.css">
(substitute the url of your style sheet for 'monk.css')

A style sheet you want to apply to more than one page is most easily done as an external style page. That page does NOT use style tags (they are html, not css), but just jumps in with tags and attributes, and their styles. Save the file with a .css extension. If you need help preparing the style sheet, there are numerous tutorials. Or do what I did and download TopStyleLite (free). It takes you a few minutes to figure out how it works, but once you get that, it's pretty easy to use. I'm assuming you know basic html and have read a bit about use of css. TopStyle is excellent for getting the syntax right, so you don't have to remember it, or keep looking it up. And, like my other favorite program, Homesite, it teaches you as you use it.



Page style sheet
<style> h1, h2, p {font-family: Ariel, sans; color: #000000; background-color: #ffffff;}
</style>


Styles placed in the HEAD section of your html page must be surrounded by STYLE tags. The form used as within the .css file, is to give an HTML tag with the designated attribues enclosed within curly braces, as you see above.

Inline styles
<TAG style="attribute:value;">styled text</TAG>
You can apply a style to a section of your page using inline styles applied to a DIV tag, or to a smaller section by applying style to any individual HTML tag, like this:
This sentence contains inline styling.


Since it's hard to remember these various syntaxes, I recommend keeping a 'snippets' file, that is, a text file with codes in it, somewhere handy so you can copy and paste from it, adapting as needed. One reason I like Homesite as a text editor is that first it helps you with the syntax, and second it provides for an easy-to-use snippets file. If you don't want to spring for Homesite, you might want to download HTML Kit. It's free and does a lot. I've just begun to delve into it. I use it pretty much for html, but it also offers assists in all sorts of other coding - ASP, perl, javascript,and more. For a free program, there is a lot there.