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
$102.50
Apple Inc.
+0.25
MSFT
$45.43
Microsoft Corpora
+0.55
GOOG
$571.60
Google Inc.
+2.40

MacTech Search:
Community Search:

Software Updates via MacUpdate

VueScan 9.4.41 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
Cloud 3.0.0 - File sharing from your men...
Cloud is simple file sharing for the Mac. Drag a file from your Mac to the CloudApp icon in the menubar and we take care of the rest. A link to the file will automatically be copied to your clipboard... Read more
LibreOffice 4.3.1.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
SlingPlayer Plugin 3.3.20.505 - Browser...
SlingPlayer is the screen interface software that works hand-in-hand with the hardware inside the Slingbox to make your TV viewing experience just like that at home. It features an array of... Read more
Get Lyrical 3.8 - Auto-magically adds ly...
Get Lyrical auto-magically add lyrics to songs in iTunes. You can choose either a selection of tracks, or the current track. Or turn on "Active Tagging" to get lyrics for songs as you play them.... Read more
Viber 4.2.2 - Send messages and make cal...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device,... Read more
Cocktail 7.6 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LaunchBar 6.1 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
BBEdit 10.5.12 - Powerful text and HTML...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more

Latest Forum Discussions

See All

Rhonna Designs Magic (Photography)
Rhonna Designs Magic 1.0 Device: iOS Universal Category: Photography Price: $1.99, Version: 1.0 (iTunes) Description: Want to sprinkle *magic* on your photos? With RD Magic, you can add colors, filters, light leaks, bokeh, edges,... | Read more »
This Week at 148Apps: August 25-29, 2014
Shiny Happy App Reviews   | Read more »
Qube Kingdom – Tips, Tricks, Strategies,...
Qube Kingdom is a tower defense game from DeNA. You rally your troops – magicians, archers, knights, barbarians, and others – and fight against an evil menace looking to dominate your kingdom of tiny squares. Planning a war isn’t easy, so here are a... | Read more »
Qube Kingdom Review
Qube Kingdom Review By Nadia Oxford on August 29th, 2014 Our Rating: :: KIND OF A SQUARE KINGDOMUniversal App - Designed for iPhone and iPad Qube Kingdom has cute visuals, but it’s a pretty basic tower defense game at heart.   | Read more »
Fire in the Hole Review
Fire in the Hole Review By Rob Thomas on August 29th, 2014 Our Rating: :: WALK THE PLANKUniversal App - Designed for iPhone and iPad Seafoam’s Fire in the Hole looks like a bright, 8-bit throwback, but there’s not enough booty to... | Read more »
Alien Creeps TD is Now Available Worldwi...
Alien Creeps TD is Now Available Worldwide Posted by Ellis Spice on August 29th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dodo Master Review
Dodo Master Review By Jordan Minor on August 29th, 2014 Our Rating: :: NEST EGGiPad Only App - Designed for the iPad Dodo Master is tough but fair, and that’s what makes it a joy to play.   | Read more »
Motorsport Manager Review
Motorsport Manager Review By Lee Hamlet on August 29th, 2014 Our Rating: :: MARVELOUS MANAGEMENTUniversal App - Designed for iPhone and iPad Despite its depth and sense of tactical freedom, Motorsport Manager is one of the most... | Read more »
Motorsport Manager – Beginner Tips, Tric...
The world of Motorsport management can be an unforgiving and merciless one, so to help with some of the stress that comes with running a successful race team, here are a few hints and tips to leave your opponents in the dust. | Read more »
CalPal Update Brings the App to 2.0, Add...
CalPal Update Brings the App to 2.0, Adds Lots of New Stuff Posted by Ellis Spice on August 29th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

The Rise of Phablets
Carlisle & Gallagher Consulting Group, a businesses and technology consulting firm focused solely on the financial services industry, has released an infographic depicting the convergence of... Read more
Eddy – Cloud Music Player for iPhone/iPad Fre...
Ukraine based CapableBits announces the release of Eddy, its tiny, but smart and powerful cloud music player for iPhone and iPad that allows users to stream or download music directly from cloud... Read more
A&D Medical Launches Its WellnessConnecte...
For consumers and the healthcare providers and loved ones who care for them, A&D Medical, a leader in connected health and biometric measurement devices and services, has launched its... Read more
Anand Lal Shimpi Retires From AnandTech
Anand Lal Shimpi, whose AnandTech Website is famous for its meticulously detailed and thoroughgoing reviews and analysis, is packing it in. Lal Shimpi, who founded the tech site at age 14 in 1997,... Read more
2.5GHz Mac mini, Apple refurbished, in stock...
The Apple Store has Apple Certified Refurbished 2.5GHz Mac minis available for $509, $90 off MSRP. Apple’s one-year warranty is included, and shipping is free. Read more
13-inch 2.5GHz MacBook Pro on sale for $999,...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Labor Day Weekend MacBook Pro sale; 15-inch m...
B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP. Shipping is free, and B&H charges NY sales tax only. They’ll also include free copies of Parallels Desktop... Read more
Labor Day Weekend iPad mini sale; $50 to $100...
Best Buy has the iPad mini with Retina Display (WiFi models) on sale for $50 off MSRP on their online store for Labor Day Weekend. Choose free shipping or free local store pick up. Price is for... Read more
13-inch 1.4GHz MacBook Air on sale for $899,...
Adorama has the new 2014 13″ 1.4GHz/128GB MacBook Air on sale for $899.99 including free shipping plus NY & NJ tax only. Their price is $100 off MSRP. Read more
It’s Official: Apple Issues Invitations To Se...
Apple has issued one of its characteristically cryptic press invitations for a special event to be held at the Flint Center for the Performing Arts in hometown Cupertino on Sept. 9, 2014 at 10:00 am... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.