Elements and classes - a side trip |
|
| The main tutorial will walk you through defining your elements and classes, but here's what they are: | |
| Elements
If you choose to define an element in your style sheet, you have a restricted set of pre-defined terms you can use. You can't invent your own, you have to use words the browsers understand. One of them is 'body' (without the quotes). If you make an element called 'body', and make it, say, Arial, 14 pixels, bold and green, then all the text within the body of your page will automatically be Arial, 14 pixels, bold and green. You don't have to do anything beyond define the element in your style sheet, and link the style sheet to your page (if it's external). No buttons to push. |
|
| Another one is 'td'. If you have an element called td, then all text within a table cell on your page will obey your instructions, and be the size, colour, weight etc. you decided when you defined that element.
Another element you can use is 'h1'. If you define that element, then whenever you specify Header 1 on your page, by using the dropdown menu, your definition of this element will show up. Another element you can use is a:link - to decide how your links will look. This gives you more control than using the inspector, where you can only set colour. Again, you don't have to apply the element - just make a link, and your definition (blue, bold, 12 pixels, underlined, whatever) will be pasted onto that link. Every time. Zero effort. |
|
| Anything sound familiar?
It should do - the elements are closely matched with the tags we looked at on the previous page. In other words, these are terms the browsers understand. They already 'read' table, body, h1 etc. correctly. With elements you are telling the browser how you want those tags interpreted, how to display everything between the relevant opening and closing tag. You won't be surprised to know that 'p' is another element you can use - for all text in a paragraph. |
|
| Back to the main css tutorial or on to classes. | |