TweetFollow Us on Twitter

Intro To Cascading Style Sheets

Volume Number: 14 (1998)
Issue Number: 6
Column Tag: WebTech

Introduction to Cascading Style Sheets

by Paola Aliverti
Contributing Editor Tantek Çelik

HTML authoring has just gotten easier: style sheets land on the Web

History

Cascading Style Sheets have been sporadically seen on the web for a while. It isn't until recently, with the latest versions of Microsoft Internet Explorer and Netscape Navigator, that they can be more widely appreciated. Style sheets on the Web work pretty much like style sheets in a word processor, or in a desktop publishing application. You can define a style called 'note' with blue text, enclosed in a border, with 24pt type set. If you need to make visual changes at a later date, all you need to do is change the defined style, without going through all the text in a page, or all the pages. CSS allows you to establish a set of rules to apply throughout the document, or, in our case, a site. Just like word-processing style sheets, Cascading Style Sheets on the Web help in a more consistent and time-saving preparation of your documents, and in styling and formatting of your documents.

The W3 Consortium has so far come up with the first list of specifications (CSS1), and is working on the second series of specs. Both Netscape 4.0 and Internet Explorer 4.0 support most of the CSS1 specs. Authoring tools are currently on the market to help you with CSS (Macromedia Dreamweaver, and Cascade, for example). You can find up-to-date information about the current CSS standards on the Web Consortium web site, at: http://www.w3.org/Style/CSS/.

HTML was designed for structure, not for style and formatting. That's why solutions like frames, and tables came along. The problem is that both of those solutions are neither straightforward nor consistent. Frames cause problems with bookmarks, and tables bloat code and promote inflexible formats.

Tables and frames will not disappear from everyday use, but style sheets will make your life much easier. If you are a web author, there will no longer be a need for tables hacks, spacer GIFs, or text-based GIFs. Style sheets allow for easy maintenance of your site, easier design, and improved control over the page layout. They help build scalable sites, uniform sites with a consistent look among browsers and platforms. If you are a web user, surfer, or cybernaut, you will like style sheets because the pages are smaller, your downloads faster, and the layout 'spiffier'. You will also like the browser scalability.

CSS allows you to re-define the look of HTML tags, add your own styling to them, or create new Classes with new characteristics.

For example, you can decide to have non-underlined links:

<A STYLE="text-decoration: none" HREF="examples.html">non-underlined link</A>

Or to have a blue <H1> tags:

<H1 STYLE="color: blue">H1 blue</H1>

Or place a dotted border around a paragraph:

<P STYLE="border: dotted blue">paragraph with dotted border</P>

NB: If you are among those who have not closed their <P> tags, it's time to start. Browsers behave much more predictably when you close the tags properly!

The basics

How does style sheet code work? Let's start with some basic terminology. In a style sheet code, there is a selector and a declaration.

A:link { text-decoration: none }

A:link is the selector, and
{ text-decoration: none } is the style declaration

The style declaration has a property (in this case 'text-declaration'), and a value ('none'). The selector can be a tag, or a newly-defined class. More specifics on different selectors can be found in the CSS1 recommendation:

Of course, even though the CSS1 properties are defined by the official spec, not all CSS-savvy browsers support all CSS1 properties. For a list of what is supported by Navigator and Explorer, you can look at:

They are not always up-to-date, but they are the best I've found so far.

There are different ways to add style sheets to your HTML code:

  • Embedding a Style Sheet
  • Linking to External Style Sheet
  • Importing an External Style Sheet
  • Adding Styles Inline

The above-mentioned examples (except the A:link example) are all inline styles. All you need to do is add the STYLE attribute to the tag you want to modify, and specify a properties and values.

If you are looking at CSS not only for styling, but for efficient site management, you don't want to be repeating the style for each instance of each tag. Let's take a look at other ways to implement style sheets...

Embedded Style Sheets

You can add your CSS code at the beginning of each HTML file you want to affect, by putting the following inside your HEAD (in your HTML <HEAD> silly!!!)

embedded.html
<HTML>
<HEAD>
<TITLE>Welcome to the fruit factory!</TITLE>
<STYLE TYPE="text/css">
<!--
H1 {color: blue}
A:link {text-decoration: none;
    color: green;
    font-size: larger;
    font-weight: bold}
P {border: dotted blue;
  text-align: center}
-->
</STYLE>
</HEAD>
<BODY>
<H1>Welcome</H1>
<P>You will find the latest and greatest news on <A HREF="topo.html">this page</A>!
</P>
</BODY>
</HTML>

Remember to hide the content of your style sheets from the old browsers with the HTML comment tag, as older browsers will ignore the <STYLE> and </STYLE> tags, but not the text in between.

Notice that different property/value pairs for the same selector should be separated by a semicolon ";".

External Style Sheet

This is my favorite implementation of CSS, as it allows you to style several files in your site, and update them by changing only one file. You can create separate external files for the different sections of your web site. A file called 'eggplant.css' can define the look and feel of the pages in all the sections of 'eggplant.com' site.

eggplant.css
H1 {color: blue}
A:link {text-decoration: none;
    color: green;
    font-size: larger;
    font-weight: bold}
P {border: dotted blue;
  text-align: center}

In the 'eggplant.com' site's pages, I will have the following code in the <HEAD> to link to the 'eggplant.css' style sheet:

<LINK REL=stylesheet HREF="eggplant.css" TYPE="text/css">

external.html
<HTML>
<HEAD>
<TITLE>Welcome to the fruit factory!<TITLE>
<LINK REL=stylesheet HREF="eggplant.css" TYPE="text/css">
</HEAD>
<BODY>
<H1>Welcome</H1>
<P>You will find the latest and greatest news on <A HREF="news.html">this page</A>!
</P>
</BODY>
</HTML>

Importing an External Style Sheet

Let's say that Eggplant is partnering with TopoCo. in a sale of Topo Mouse dolls, and I need to add TopoCo.'s traditional style to my Eggplant site. I can do this by adding to my previously-mentioned 'eggplant.css' file one line of code: @import url(topo.css)

import.css
H1 {color: blue}
A:link {text-decoration: none}
P {border: dotted blue}
@import url(topo.css)

You can import as many style sheets as you like (but beware of possible conflicts, as the next sections explain...). There are already collections of style sheets available on the web http://www.microsoft.com/gallery/files/styles, and expect more in the future. Importing style sheets can come pretty handy when you don't feel like creating the files yourself. Of course, you should be aware not only of the legal implications of taking someone else's work, and use it in your own site, but also of the stability of the site you are linking to.

As far as I can tell, though, it's something you don't have to worry about, yet, because only one version of the common browsers supports imported style sheets (Internet Explorer 4.0 for the Mac).

Order of importance

As you probably already guessed from looking at the examples above, you can mix and match any of the methods of implementation of CSS. Which one is more important? And which one will prevail, in case two of them conflict? Although many references attempt to explain (see comments about CSS1, and CSS2 specs in the next section), the correct order of importance is the following:

  1. Inline Styles.
  2. Embedded, Linked, and Imported Style Sheets.
  3. User preferences.
  4. Browser's default settings.

Now let's move on to the next section to find out what prevails when styles conflict.

Cascading Abilities, Inheritance, Conflicts

As you probably already guessed from looking at the examples above, browsers need firm rules of cascading and inheritance for different style sheets, or implementations thereof, in order to avoid chaos. The specs of CSS1 differ a bit from CSS2 in this matter. According to my research, browsers have already started to support CSS2 rules. I will skip the CSS1 rules, and just discuss the CSS2 cascade rules, which, apart from being the latest, also seem more logical. Here is the first set of rules:

  1. Follow specific declarations, or, if there aren't any, inherit values.
  2. Sort declarations by importance.
  3. Sort by specificity of selector.
  4. Finally, among selectors of equal specificity, the latest onewins.

As most of the current versions of CSS browsers do not support factor 2 (the 'important' modifier), I will concentrate on the cascading declarations and inheritance.

The first rule can be divided in two simple rules:

  1. Cascading takes precedence over inheritance.
  2. Follow the order in which the styles appear, considering the latest (closest to the text to which it refers) style the most important.

Let's take a look at what cascading and inheritance mean.

Cascading declarations and inheritance

inherit.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
H1 {color: blue}
BODY {text-decoration: none;
   color: navy}
A:link {text-decoration: underline;
    color: green}
P {font-style: italic}
-->
</STYLE>
<TITLE>Welcome to the veggie factory!</TITLE>
</HEAD>
<BODY>
<H1>Welcome</H1>
<P>You will find the latest and greatest news on <A HREF="latest.html">this page!</A></P>
</BODY>
</HTML>

All the text within the <BODY> tag should be navy, and not underlined. The <H1> tag is within the body tag. It will then appear not underlined. The <H1> tag has its own declaration rule to follow, and it will appear as blue.

The text within <P> will be in italic, and it will inherit the color specified in BODY, because it has no color declarations of its own. The link tag <A>, though, has its own rule, and will display in green, while inheriting the italic style of the <P> tag.

How can you tell which properties inherit? A simple rule might be this: pure adornment properties inherit, formatting properties don't. E.g.: a color property will inherit. A positioning property won't. One notable exception to this rule: background and border, which can be considered adornment properties, do not inherit.

Cascading declarations and order

order.html
<HTML>
<HEAD>
<STYLE TYPE="text/CSS">
<!--
B { font-family: courier;
  color: blue}
B { font-family: arial;
  color: yellow}
-->
</STYLE>
<TITLE>CSS is fun!</TITLE>
</HEAD>
<BODY>
<B>
Is this text yellow or blue? Arial or Courier?!
</B>
</BODY>
</HTML>

The text will appear yellow arial, because the second rule wins over the first rule.

Conflicts

What happens if style sheets conflict with a standard HTML tag? The style sheet rules take precedence.

conflict.html
<HTML>
<HEAD>
<STYLE TYPE="text/CSS">
<!--
BODY { font-family: arial;
    color: yellow}
-->
</STYLE>
<TITLE>CSS are fun!<TITLE>
</HEAD>
<BODY COLOR=blue>
Style sheets take precedence over HTML tags. This text is yellow arial.
</BODY>
</HTML>

The browsers seem to behave differently, not only depending on the versions, but on the platform, as well. The ever-valid web authoring rule applies even to style sheets: test on all possible configurations before publishing online.

The most accurate sources of information I have found on and offline about browsers support are:

Web Designer's Guide to Style Sheets, by Steven Mulder, Hayden Books. ISBN# 1-56830-306-8,

http://www.webreview.com/guides/style/.

Classes, Ids, Contextual Selectors

If you need to style different tags in the same fashion (e.g.: highlighting anything with a yellow background), or the same tag in different ways (e.g.: three different kinds of underlining, according to where the links appear), you can define classes within your style sheet.

class.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
.hilite {background-color: yellow}
-->
</STYLE>
<TITLE>Highlight what's important</TITLE>
</HEAD>
<BODY>
<H1>Highlight what's <SPAN CLASS="hilite">important</SPAN></H1>
With style sheets, you can <SPAN CLASS="hilite">highlight</SPAN> the important parts of your document.
</BODY>
</HTML>

Hilite is declared as a class selector by preceding it with a period "." The <SPAN> tag is essentially just a vehicle for applying a style to a range of content, it has no intrinsic effect of its own. The CLASS attribute inside the SPAN tag then binds it to the style declared for the indicated class.

class2.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
P.green {background-color: green;
     color: red}
P.yellow {background-color: yellow;
     color: green}
P.orange {background-color: orange;
     color: purple}
P.red {background-color: red;
     color: blue}
P.purple {background-color: purple;
     color: yellow}
P.blue {background-color: blue;
    color: orange}
-->
</STYLE>
</HEAD>
<BODY>
<H1>My favorite colors</H1>
<P CLASS="green">In this line we will talk about the color green.</P><BR>
<P CLASS="yellow">In this line we will talk about the color yellow.</P><BR>
<P CLASS="orange">In this line we will talk about the color orange.</P><BR>
<P CLASS="red">In this line we will talk about the color red.</P><BR>
<P CLASS="purple">In this line we will talk about the color purple.</P><BR>
<P CLASS="blue">In this line we will talk about the color blue.</P><BR>
</BODY>
</HTML>

The class2.html example demonstrates tag specific class selectors. Only <P> tags with the respective classes will bind to the styles declared. Other tags with classes won't be affected. You can also use HTML 3 ID attributes instead of CLASSES to define a new style. In this case, the ID will work as a selector.

id.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
#bggrtxr {background-color: green;
     color: red}
-->
</STYLE>
</HEAD>
<BODY>
<H1>My favorite colors</H1>
<P>In this line we will talk about the <SPAN ID="bggrtxr">color green.</SPAN><BR>
</BODY>
</HTML>

You can also have a sequence of tags for a selector, creating contextual selectors. In this case, the CSS rules will apply to tags which have the indicated parent-child relationship.

conindex.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
H1 I B {background-color: yellow} 
-->
</STYLE>
</HEAD>
<BODY>
<H1>More<I> <B>highlights!</B></I></H1>
<P>In this line we will talk about the <I><B>contextual selectors.</B></I><BR>
</BODY>
</HTML>

In this case, 'contextual selectors' is bold and italic, but is not highlighted because it is not contained within the <H1>. 'Highlights!', on the other hand does appear with a yellow background.

Style Sheet Properties

Here is a review of the main properties and their values. I recommend you look at the books or URLs listed at the bottom of the page, and test your pages thoroughly, to make sure that the properties are properly supported across browsers. Be sure to check the CSS1 Recommendation and the latest CSS2 Working Draft for the complete details on particular properties and values.

Possible values are listed after the colon, separated by a vertical bar "|", meaning 'or', or by a double vertical bar "||", meaning and/or.

Common values

Many style properties take the similar values. Here is a summary of the most common value types and what they mean. In the list of properties, I will simply list <length> when a property can be defined in inches, centimeters, etc.

Length

length is expressed in inches (in), centimeters (cm), millimeters (mm), points (pt), picas (pc), em (em), x-height (ex), or pixels (px).

Percentage

percentage is expressed in comparison to the standard size or size of one's parent tag. 150% means that the font-size, for example, is one and a half times the size of the parent tag's font-size.

Color
Any of the pre-defined standard web colors.
{1,4}
Appears in properties that can take from one to four values. They indicate the top, right, bottom, and left values respectively for the property. E.g.:
Margin:
<length> | <percentage | auto {1,4} means that the four values of margin can be listed as follows: <P> {margin: 20px 10px 20px 10px}

Properties

Fonts

  • font-family: <family name>, .. || <generic name> where <family> : helvetica |arial | times | etc. and <generic> : serif | sans-serif | cursive | fantasy | monospace.
  • font-size: <absolute> | <relative> | <length> | <percentage> where <absolute>: xx-small | x-small | small | medium | large | x-large | xx-large and <relative>: smaller | larger
  • font-style: normal | italic | oblique
  • font-weight: extra-light | light | demi-light | medium | normal | demi-bold | bold | extra-bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
  • font-variant: normal | small-caps
  • text-transform: capitalize | uppercase | lowercase | none
  • text-decoration: none | underline | overline | line-through | blink

Color and Background

  • color: <color>
  • background-color: transparent | <color>
  • background-image: <url> | none
  • background-repeat: repeat | repeat-x | repeat-y | no-repeat
  • background-attachment: scroll | fixed
  • background-position: <percentage> | <length> | top | center | bottom | left | right
  • background by itself also takes any of the above values.

Space and Layout

  • word-spacing: normal | <length>
  • letter-spacing: normal | <length>
  • line-height: normal | number | length | percentage
  • text-align: left | right | center | justified
  • text-indent: <length> | percentage
  • vertical-align: baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage>
  • margin: <length> | <percentage | auto {1,4}. In lieu of the shorthand margin, you can also use the more specific: margin-top, margin-right, margin-bottom, margin-left.
  • padding: <length> | <percentage> {1,4} In lieu of the shorthand padding, you can also use the more specific: padding-top, padding-right, padding-bottom, padding-left.
  • border-width: thin | medium | thick | <length> {1,4} In lieu of the shorthand border-width, you can also use the more specific: border-top-width, border-right-width, border-bottom-width, and border-left-width.
  • border-color: <color> {1,4}
  • border-style: none | dotted | dashed | solid | double | groove | ridge | inset | outset {1,4}
  • border: <border-width> ||<border-style> || <border-color> In lieu of the shorthand border, you can also use the more specific: border-top, border-right, border-bottom, and border-left.
  • width: <length> | <percentage> | auto
  • height: <length> | auto
  • float: left | right | none
  • clear: none | left | right | both

Positioning

  • position: absolute | relative | static
  • left: <length> | <percentage> | auto
  • top: <length> | <percentage> | auto
  • width: <length> | <percentage> | auto
  • height: <length> | <percentage> | auto
  • overflow: none | clip | scroll
  • z-index: auto | <integer>
  • visibility: inherit | visible | hidden

Classification

  • display: block | inline | list-item | none
  • white-space: normal | pre | nowrap
  • list-style: <keyword> || <position || <url> where <keyword>: disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none <position>: inside | outside and <url>: <url> | none

In lieu of the shorthand list-style, you can also use the more specific: list-style-type, list-style-image, and list-style-position.

Fun with Style Sheets

Here are a few examples that will hopefully give you an idea of how much fun you can have with style sheets. The examples are sample code that you can use, but they are not guaranteed to be a complete, scalable solutions for all browsers and platforms.

Rollover effect

rollover.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
A:link {color: navy;
    text-decoration: none;
    font-size: 40pt;
    font-family: helvetica, arial}
A:active {color: orange}
A:hover {font-weight: bold;
     color: red}
-->
</STYLE>
<TITLE>Rollover effect</TITLE>
</HEAD>
<BODY>
This example will work for Internet Explorer 4.0 Mac users:<BR>
<A HREF="rollover.html">ROLLOVER EFFECT</A>
</BODY>
</HTML>

Unfortunately, this example will work only with Internet Explorer 4.0 for the Mac. But considering how little it takes to implement it, why not add a little excitement just for your Internet Explorer Mac users?

Navigation bar

navigation.html
<HTML>
<HEAD>
<TITLE>navigate with CSS</TITLE>
<STYLE TYPE="text/css">
A:link {color: blue}
A:visited {color: navy}
A:active {color: orange}
A:hover {color: red}

A.nav:link {color: white}
A.nav:visited {color: #3300FF}
A.nav:active {color: yellow}
A.nav:hover {color: yellow}

.bar {line-height: 150%;
   background-color: #FF0000;
   font-weight: bold;
   font-family: helvetica}
</STYLE>
</HEAD>
<BODY>
<CENTER>
<DIV CLASS="bar">
<A CLASS="nav" HREF="home.html">home</A> | 
<A CLASS="nav" HREF="about.html">about us</A> | 
<A CLASS="nav" HREF="prod.html">products</A>| 
<A CLASS="nav" HREF="news.html">news</A> | 
</DIV>
</CENTER>
</BODY>
</HTML>

This is a simple navigation bar, that takes advantage of the <A> and <DIV> tags, and the "nav", and "bar" classes.

'bar' defines the 'spine' of our bar. It sets the font to use (helvetica), the weight (bold), the background color (some sort of red), and the line-height (150%), which gives the 'bar' effect. To set the line-height, you could also use a number (\ the browser will multiply that number by the font-size specified), or a value, such as 'em' or 'pt'.

'nav' decides the behavior of the different <A> tags. We can safely set the link color to white, because if the browser doesn't recognize CSS, it will not display any of the values.

Horizontal rule

hr.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
.hr {background-image: url(plane.gif);
   width: 70%;
   line-height: 150%;
   text-align: center}
</STYLE>
<TITLE>Nice horizontal rule</TITLE>
</HEAD>
<BODY><CENTER>
Da plane, da plane!<BR>
Da plane, da plane!<BR>
<SPAN CLASS="hr"><BR></SPAN>
<BR>
Da plane, da plane!<BR>
Da plane, da plane!<BR>
Da plane, da plane!<BR>
</CENTER></BODY>
</HTML>

You can take a logo or a small image and use it as a background image to create a different kind of horizontal rule.

Chapter divider

chapdiv.html
<HTML>
<HEAD>
<STYLE TYPE="text/css">
.hr {width: 100%;
   border-top: thick solid red;
   color: red;
   text-align: left;
   font-size: 24pt;
   font-weight: bold;
   font-family: arial}
</STYLE>
<TITLE>Chapter divider</TITLE>
</HEAD>
<BODY>
<P>This example will show you how to divide different sections of your page:</P>
<DIV CLASS="hr">Company</DIV>
Here is where we talk about the company.
<DIV CLASS="hr">Products</DIV>
Here is where we talk about the products.
<DIV CLASS="hr">News</DIV>
Here is where we talk about the news.
</BODY>
</HTML>

This divider is ideal to break out chapters or sections of your page, in a book-like format familiar to your user.

Shapes and colors

eggplant.html
<HTML>
<HEAD>
<TITLE>Company's logo</TITLE>
</HEAD>
<BODY>
<SPAN STYLE="COLOR: green; POSITION: absolute; TOP: 5px; LEFT: 180px; font-weight: bold; font-size: 32pt; font-style: italic">!</SPAN><BR>
<SPAN STYLE="COLOR: green; POSITION: absolute; TOP: 20px; LEFT: 170px; font-weight: bold; font-size: 32pt; font-style: italic">!!</SPAN><BR>
<SPAN STYLE="COLOR: green; POSITION: absolute; TOP: 40px; LEFT: 170px; font-weight: bold; font-size: 32pt; font-style: italic">!</SPAN><BR>
<SPAN STYLE="COLOR: green; POSITION: absolute; TOP: 70px; LEFT: 105px">Green. Green. Green. Green.</SPAN><BR>
<SPAN STYLE="COLOR: green; POSITION: absolute; TOP: 80px; LEFT: 100px">GreenGreenGreenGreenGreen</SPAN><BR>
<SPAN STYLE="COLOR: yellow; POSITION: absolute; TOP: 90px; LEFT: 95px">Yellow.Yellow.Yellow. Yellow. </SPAN><BR>
<SPAN STYLE="COLOR: yellow; POSITION: absolute; TOP: 100px; LEFT: 92px">Yellow.Yellow. Yellow.Yellow. </SPAN><BR>
<SPAN STYLE="COLOR: orange; POSITION: absolute; TOP: 110px; LEFT: 92px">Orange.Orange.Orange.Orange.</SPAN><BR>
<SPAN STYLE="COLOR: orange; POSITION: absolute; TOP: 120px; LEFT: 95px">Orange.Orange.Orange.Orange.</SPAN><BR>
<SPAN STYLE="COLOR: red; POSITION: absolute; TOP: 130px; LEFT: 95px">Red.Red.Red.Red.Red.Red.Red.</SPAN><BR>
<SPAN STYLE="COLOR: red; POSITION: absolute; TOP: 140px; LEFT: 100px">Red.Red.Red.Red.Red.Red.Red.</SPAN><BR>
<SPAN STYLE="COLOR: purple; POSITION: absolute; TOP: 150px; LEFT: 105px">Purple. Purple. Purple. Purple.</SPAN><BR>
<SPAN STYLE="COLOR: purple; POSITION: absolute; TOP: 160px; LEFT: 110px">Purple.Purple.Purple.Purple.</SPAN><BR>
<SPAN STYLE="COLOR: blue; POSITION: absolute; TOP: 170px; LEFT: 120px">Blue. Blue. Blue. Blue.</SPAN><BR>
<SPAN STYLE="COLOR: blue; POSITION: absolute; TOP: 180px; LEFT: 125px">Blue.Blue.Blue.Blue.</SPAN><BR>
</BODY>
</HTML>

This example might give you ideas for a different kind of ASCII art!

Positioning

examples.html
<HTML>
<HEAD>
<TITLE>Intro to CSS</TITLE>
<STYLE TYPE="text/css">
A:link {color: blue}
A:hover {color: cyan}
</STYLE>
</HEAD>
<BODY>
<CENTER>
<SPAN STYLE="color: black; position: absolute; top: 20px; left: 50px; font-weight: bold; font-size: 48pt; font-family: arial, helvetica">Introduction to</SPAN>
<SPAN STYLE="color: cyan; position: absolute; top: 50px; left: 200px; font-weight: bold; font-size: 48pt; font-family: arial, helvetica">Cascading</SPAN>
<SPAN STYLE="color: navy; position: absolute; top: 75px; left: 150px; font-weight: bold; font-size: 48pt; font-family: arial, helvetica">Style</SPAN>
<SPAN STYLE="color: blue; position: absolute; top: 100px; left: 250px; font-weight: bold; font-size: 48pt; font-family: arial, helvetica">Sheets</SPAN>
<SPAN STYLE="color: blue; position: absolute; top: 4px; left: 330px; font-size: 28pt; font-family: times, helvetica"><A HREF="/">MacTech, June 1998</A></SPAN>
</CENTER>
<SPAN STYLE="position: absolute; top: 150px; left: 50px">
<H2>The basics</H2>
<A HREF="embedded.html">embedded</A><BR>
<A HREF="external.html">sample</A> of <A HREF="eggplant.css">external file</A><BR>
<A HREF="inherit.html">inheritance</A><BR>
<A HREF="order.html">order</A><BR></SPAN>
<A HREF="conflict.html">conflict</A><BR>
<A HREF="class.html">class, example 1</A><BR>
<A HREF="class2.html">class, example 2</A><BR>
<A HREF="id.html">ID</A><BR>
<A HREF="conindex.html">contextual </A><BR>
<SPAN STYLE="position: absolute; top: 150px; left: 250px">
<H2>Fun with Style Sheets</H2>
<A HREF="rollover.html">rollover</A><BR>
<A HREF="navigation.html">navigation</A><BR></SPAN>
<A HREF="hr.html">horizontal rule</A><BR>
<A HREF="chapdiv.html">chapter divider</A><BR>
<A HREF="eggplant.html">eggplant</A><BR>
<A HREF="eggplant.html">eggplant</A><BR>
</BODY>
</HTML>

Amazing what you can accomplish with positioning, isn't it?

References

There are many HTML authoring books that have sections about CSS, but I would suggest looking at more specific guides. Here is a list of my favorite references:

Books

  • "Web Designer's Guide to Style Sheets", by Steven Mulder, Hayden Books - http://www.hayden.com/internet/style
  • "Cascading Style Sheets - Designing for the Web", by Häkon Wium Lie and Bert Bos, Addison Wesley.

URLs

A Few Sites that use CSS


Paola Aliverti is a web designer at New Software, Inc. in Palo Alto, CA. In her previous life, she was a software developer, and a translator. She can be reached at Paola@Paola.com.

 
AAPL
$99.76
Apple Inc.
+2.09
MSFT
$44.08
Microsoft Corpora
+0.45
GOOG
$520.84
Google Inc.
+9.67

MacTech Search:
Community Search:

Software Updates via MacUpdate

TechTool Pro 7.0.5 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PDFKey Pro 4.0.2 - Edit and print passwo...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Yasu 2.9.1 - System maintenance app; per...
Yasu was originally created with System Administrators who service large groups of workstations in mind, Yasu (Yet Another System Utility) was made to do a specific group of maintenance tasks... Read more
Hazel 3.3 - Create rules for organizing...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a... Read more
Autopano Giga 3.7 - Stitch multiple imag...
Autopano Giga allows you to stitch 2, 20, or 2,000 images. Version 3.0 integrates impressive new features that will definitely make you adopt Autopano Pro or Autopano Giga: Choose between 9... Read more
MenuMeters 1.8 - CPU, memory, disk, and...
MenuMeters is a set of CPU, memory, disk, and network monitoring tools for Mac OS X. Although there are numerous other programs which do the same thing, none had quite the feature set I was looking... Read more
Coda 2.5 - One-window Web development su...
Coda is a powerful Web editor that puts everything in one place. An editor. Terminal. CSS. Files. With Coda 2, we went beyond expectations. With loads of new, much-requested features, a few... Read more
Arq 4.6.1 - Online backup to Google Driv...
Arq is super-easy online backup for the Mac. Back up to your own Google Drive storage (15GB free storage), your own Amazon Glacier ($.01/GB per month storage) or S3, or any SFTP server. Arq backs up... Read more
Airfoil 4.8.10 - Send audio from any app...
Airfoil allows you to send any audio to AirPort Express units, Apple TVs, and even other Macs and PCs, all in sync! It's your audio - everywhere. With Airfoil you can take audio from any... Read more
Apple iMovie 10.0.6 - Edit personal vide...
With an all-new design, Apple iMovie lets you enjoy your videos like never before. Browse your clips more easily, instantly share your favorite moments, and create beautiful HD movies and Hollywood-... Read more

Latest Forum Discussions

See All

This Week at 148Apps: October 13-17, 201...
Expert App Reviewers   So little time and so very many apps. What’s a poor iPhone/iPad lover to do? Fortunately, 148Apps is here to give you the rundown on the latest and greatest releases. And we even have a tremendous back catalog of reviews; just... | Read more »
Angry Birds Transformers Review
Angry Birds Transformers Review By Jennifer Allen on October 20th, 2014 Our Rating: :: TRANSFORMED BIRDSUniversal App - Designed for iPhone and iPad Transformed in a way you wouldn’t expect, Angry Birds Transformers is a quite... | Read more »
GAMEVIL Announces the Upcoming Launch of...
GAMEVIL Announces the Upcoming Launch of Mark of the Dragon Posted by Jessica Fisher on October 20th, 2014 [ permalink ] Mark of the Dragon, by GAMEVIL, put | Read more »
Interview With the Angry Birds Transform...
Angry Birds Transformers recently transformed and rolled out worldwide. This run-and-gun title is a hit with young Transformers fans, but the ample references to classic Transformers fandom has also earned it a place in the hearts of long-time... | Read more »
Find Free Food on Campus with Ypay
Find Free Food on Campus with Ypay Posted by Jessica Fisher on October 20th, 2014 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
Strung Along Review
Strung Along Review By Jordan Minor on October 20th, 2014 Our Rating: :: GOT NO STRINGSUniversal App - Designed for iPhone and iPad A cool gimmick and a great art style keep Strung Along from completely falling apart.   | Read more »
P2P file transferring app Send Anywhere...
File sharing services like Dropbox have security issues. Email attachments can be problematic when it comes to sharing large files. USB dongles don’t fit into your phone. Send Anywhere, a peer-to-peer file transferring application, solves all of... | Read more »
Zero Age Review
Zero Age Review By Jordan Minor on October 20th, 2014 Our Rating: :: MORE THAN ZEROiPad Only App - Designed for the iPad With its mind-bending puzzles and spellbinding visuals, Zero Age has it all.   | Read more »
Hay Ewe Review
Hay Ewe Review By Campbell Bird on October 20th, 2014 Our Rating: :: SAVE YOUR SHEEPLEUniversal App - Designed for iPhone and iPad Pave the way for your flock in this line drawing puzzle game from the creators of Worms.   | Read more »
My Very Hungry Caterpillar (Education)
My Very Hungry Caterpillar 1.0.0 Device: iOS Universal Category: Education Price: $3.99, Version: 1.0.0 (iTunes) Description: Care for your very own Very Hungry Caterpillar! My Very Hungry Caterpillar will captivate you as he crawls... | Read more »

Price Scanner via MacPrices.net

2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
Updated iPad Prices
We’ve updated our iPad Air Price Tracker and our iPad mini Price Tracker with the latest information on prices and availability from Apple and other resellers, including the new iPad Air 2 and the... Read more
Apple Pay Available to Millions of Visa Cardh...
Visa Inc. brings secure, convenient payments to iPad Air 2 and iPad mini 3as well as iPhone 6 and 6 Plus. Starting October 20th, eligible Visa cardholders in the U.S. will be able to use Apple Pay,... Read more
Textkraft Pocket – the missing TextEdit for i...
infovole GmbH has announced the release and immediate availability of Textkraft Pocket 1.0, a professional text editor and note taking app for Apple’s iPhone. In March 2014 rumors were all about... Read more
C Spire to offer iPad Air 2 and iPad mini 3,...
C Spire on Friday announced that it will offer iPad Air 2 and iPad mini 3, both with Wi-Fi + Cellular, on its 4G+ LTE network in the coming weeks. C Spire will offer the new iPads with a range of... Read more
Belkin Announces Full Line of Keyboards and C...
Belkin International has unveiled a new lineup of keyboard cases and accessories for Apple’s newest iPads, featuring three QODE keyboards and a collection of thin, lightweight folios for both the... Read more
Verizon offers new iPad Air 2 preorders for $...
Verizon Wireless is accepting preorders for the new iPad Air 2, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB iPad Air 2 WiFi... Read more
Price drops on refurbished Mac minis, now ava...
The Apple Store has dropped prices on Apple Certified Refurbished previous-generation Mac minis, with models now available starting at $419. Apple’s one-year warranty is included with each mini, and... Read more
Apple refurbished 2014 MacBook Airs available...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more
Refurbished 2013 MacBook Pros available for u...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available starting at $929. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros (4GB RAM/... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** At the Apple Store, you connect business professionals and entrepreneurs with the tools they need in order to put Apple solutions to work in their Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** The Apple Store is a retail environment like no other - uniquely focused on delivering amazing customer experiences. As an Expert, you introduce people Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** As businesses discover the power of Apple computers and mobile devices, it's your job - as a Solutions Engineer - to show them how to introduce these Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.