More CSS Styling
October 22nd, 2001
CSS is a great way to add "style" to the graphical output of HTML pages.
Look at the two code samples below, a form textarea and an input button. See
how they have been spiced up with CSS Styles!
Notice the addition of a style attribute to these 2 examples? Why not grab
the code and take a look at them in your favorite editor?
Of course, not all of these attributes will be processed by all browsers, so
it is always a good idea to define attributes in raw HTML wherever possible
also. For example, the SPAN tag is a handy tool you can use to define
attributes of fonts, table cells etc. But these attributes may not dispay
properly in older browsers. To get the best display, we hard code HTML
values outside of the SPAN tag. Here is an example:
This text is
red.
Now, why would you want to complicate things by using both CSS and HTML?
Because there are many more attributes available in CSS. For instance, we
could set an abnormal font size, mouse-over effect or other attributes to
this font, which will not display by old browsers. The HTML coding outside
of our span ensures at least a likeness of our span charactaristics for such
browsers.
Here is an example of a CSS Style for the Table Cell tag:
| Notice the underline? This is not defined in a font or underline tag, but the table cell itself!! |