HTML Cookbook Basic HTML Course

It's Easy!

CSS Step By Step


Alternate version

CSS Comments and Attributes


CSS Comments

In HTML, we have a comment tag that allows us to add notes to ourself or anyone else that might see our code. It has the form:
<!-- comment -->

CSS also has a comment that can be used in stylesheets.
It opens with a slash and an asterisk: /*
and closes with an asterisk and a slash: */.
The comment itself goes in between.

Complete form:
/* comment goes here */

or

/*
comment goes here
comment goes here
comment goes here
*/


Let's look at an example in a stylesheet.


/* my link colors */
a:link { color: #0000ff; }
a:visited { color: #800000; }
a:active { color: #ff00ff; }



CSS Attributes, Part 1

In Lesson 2 we learned how to apply a style directly to an element in a page using the form:
<tag style="property: value">.

At the time, it was mentioned that this looks like an atrribute does in an html element. In fact, that is exactly what it is. CSS has 3 attributes: style, class and id.


Style

Hey, we already learned this one. All right! The style attribute allows us to apply a style to any element. Later, we'll learn how to apply a style to just a few words or a phrase. In the meantime, here is another example that uses 2 font stylings that we will cover soon.

Example

This code:
<p style="font-size:24pt; font-weight:bold; color:#6699ff;">
This paragraph has large, bold, light blue text.
</p>

produces:

This paragraph has large, bold, light blue text.

We'll learn a more efficient way to get the above effect in our next lesson, when we discuss the class and id attributes.

Assignment

Use a CSS comment in your stylesheet. Post the URL for your stylesheet and/or page.

Our Mantra:
I love CSS!
CSS is my friend!
I AM the mighty creator!

Happy coding!
Gnubee

Links
Tips
Tools
References
Rules
HTML Help Gnubee - Newsgroup
HTML Course Contents (Home)

Valid XHTML 1.0!

Valid CSS!