When you read a book
you'll notice that the first line of a paragraph is usually indented. Until
CSS came along, there was no simple way to do this on web pages.
If you'd like to
indent the first line of your paragraphs, just paste the following into
the HEAD section of your page or add the middle line of code to your linked
stylesheets:
<style type="text/css">
<!--
p { text-indent: 2em;}
-->
</style>
So let's see what
that looks like. Be sure you pull down the code to see WHERE I placed it.
(Go to 'VIEW' then 'SOURCE')
With CSS you can highlight
text on a page, making it look like you ran a yellow highlight marker over
it. This is great for emphasizing important words or points.
Just add this code
to the HEAD section of your HTML page:
<style type="text/css">
<!--
.HL {background: #ffff99;
color: #000000;}
-->
</style>
What you've done
is create a CSS class, and now the table is set. To use it to highlight
a passage, you could write:
<font class="HL">this
is highlighted</font>
The words "this is
highlighted" will have a yellow background with black text. Of course,
you can change those colors to anything you want by modifying the colors
in the CSS code.
Let's not stop there.
OK? What about if we wanted to highlight an entire paragraph? If you don't
like messing with tables, try this style tag:
<P style="background-color:
FEE333";>
All of the text in
the above paragraph will be highlighted in yellow-orange. To change that
color, just substitute any other hex code or use a color name.
This CSS tag works
in both Netscape and Internet Explorer.
SPACING
FOR LINES & PARAGRAPHS
Sometimes the designer
(YOU) doesn't want so much space between paragraphs. (Like when using bullets
or such) You can control the space between paragraphs -- and lines -- like
this:
You can set the line
height for paragraphs with a little CSS in the HEAD section of your HTML
document, like this:
<style type="text/css">
<!--
P {line-height : 12px;}
-->
</style>
Just change the "12px"
to however many pixels you need it to be. The comment tags should be included
to prevent crotchety older browsers from displaying the code.
You can set the line
height for paragraphs with embedded style sheets -- CSS in the HEAD section
of your HTML document -- like this:
<style type="text/css">
<!--
p {line-height : 20px;}
-->
</style>
Just change the "20"
in 20px (pixels) to the number you need.
You can also place
the CSS code right in your HTML tag, as an inline style.
<p style="line-height: 20px;">
Both methods accomplish
the same thing. The advantage of embedding them in the HEAD section is
that the line height will be applied every time you use a <p> tag. With
the inline style, you have to insert the CSS code into each paragraph
Now let's see what
it looks like, both in CODE and diplayed in the browser.
CLICK
HERE to see the examples. (Come back when you're done and we'll look
at something pretty cool... :-)
CSS
UNDERLINE/OVERLINE LINKS
There are some
very cool ways to handle links in your page. Here's one that uses the CSS
to make your links look different. Just try underlining AND overlining
them, framing them between horizontal lines. Just add:
to the HEAD section
of your page. The underline and overline will display whenever a visitor
moves the cursor over the links.
A variation: If you
remove the word "underline" from the above code, the link will be underlined
(with no overline) at rest, and overlined (with no underline) when a visitor's
cursor is hovering over it.
There is a lot you can
do with CSS. Here's an example of CSS working with form elements. Form
elements can be a bit boring...so we're going to liven things up a bit.
Let's first start
with a simple head tag that will color all the elements in a text field
box.
Now on to the final
CSS trick. Are you still with me? Good.
**
CSS LINK MENU **
We're going to create
a menu using CSS only. Awesome stuff here. I won't take up space here to
list the code. Just look at it in the popup window and copy the code from
'view source'.