Microsoft Visual Web Developer "Fun" Design Template

2005 - designed and documented new web page templates for Microsoft Visual Studio 2005 version.

human factors

templates use the XHTML 1.1 Strict doctype and will work smoothly in IE6 Windows, Safari Mac OSX, Firefox Win XP and Mac OSX. Best practices for CSS and web standards are used. This includes Section 508 conformance and best practices for non-visual browser scenarios

marketing

these templates give developers a starting place for web site look and feels, but equally important, these templates show developers how to use CSS, XHTML Strict, how to conform to Section 508 guidelines and how to make their code accessible to non-visual browsers and search engines, the documentation for each template shows how user can easily customize the templates.

technology

Photoshop, Visual Web Developer, Illustrator, advanced CSS layouts, XHTML Strict Doctype

aeSthetics

simple and fun, pseudo 3d blocks with bold red links, there is also a red theme for this template made of CSS and just a few images

about the samples below

screen shot and documentation, this template will be released in the summer of 2005



Documentation for the Microsoft Visual Studio "Fun" Design Template. The layout for this template is built with DIVs and CSS.

  1. About the Visual Studio Design Templates
  2. Table layouts versus DIV layouts
  3. Usability & Accessibility
    • Summary
    • Why read this section?
    • Many different kinds of browsers
    • Page titles
    • Alternative text and titles for graphics
    • Browser size and "above the fold"
    • Using relative font sizes
    • Making forms accessible
    • Making tables accessible
    • Acronyms and abbreviations
    • Breadcrumbs
    • Allow non-visual browsers to skip past repetitive navigation links
    • Section 508 conformance
      • What is Section 508?
      • Section 508 checklists
      • How this template conforms
      • How your code can conform
    • Web Content Accessibility Guidelines (WCAG)
    • How good usability helps optimize your site for search engines
    • Resources
      • "Bobby" can help test the usability of your site
      • The AIS Web Accessibility Toolbar for Internet Explorer can help test the usability of your site
  4. HTML Mark-Up
    • XHTML strict doctype
    • Why use the XHTML strict?
    • Adding the favicon.ico to your header
    • Keeping styles out of the HTML mark-up
    • Using DIVs for layout
    • Heading tags (used to build an outline, not to make fonts larger)
    • Forms
    • Showing data in tables
      • Summary
      • Table headings, table footers and table bodies (THEAD, TFOOT and TBODY)
      • Column groups (COLGROUP)
  5. Targeted browsers
  6. Cascading Style Sheets
    • Why use CSS
    • What is a CSS rule?
    • CSS selectors (classes, ID's or HTML tags)
      • The difference between classes and IDs
      • IDs as CSS selectors
      • Classes as CSS selectors
      • Class and ID naming guidelines
    • Links & pseudo classes (LINK, HOVER, ACTIVE, VISITED)
    • Heading tags
    • Form tags
    • Lists as menus (horizontal or vertical)
    • Specifying font families
    • Creating the layout with DIVs
      • What is a DIV?
      • How padding, margin and width work on DIVs
      • CSS Shorthand
      • Floating DIVs
      • Using container DIVs and the CSS clear attribute
      • The 5 layout types included in the Microsoft Visual Studio Design Templates
      • How to create this template's three column layout with DIVs and CSS
    • Background images
      • Summary
      • Include a background color along with the background image
      • Specifying the repeat value x, y or none
      • Specifying the horizontal position value right, left, center or amount
      • Specifying the vertical position top, center, bottom or amount
  7. Validating your pages
    • Summary
    • CSS validation
    • HTML validation
    • "Bobby" can help validate your site's usability
  8. Aesthetics
    • Use of scale
    • Use of color
    • Fonts families
    • Details add polish
    • "Poster" photo
    • Making the favicon.ico file
    • A note on consistency
  9. Extending this Template
    • Changing the colors
    • Changing the "poster photo"
    • Adding a bit map logo instead of the "site name" text
  10. Quick Tips and Tricks
  11. Web Links, References & Tools
    • Any specific Microsoft links to include?
    • HTML validation
    • CSS validation
    • Official Section 508 Web Site
    • The AIS accessibility toolbar for Internet Explorer

About the Visual Studio Design Templates

Microsoft has created a set of five design templates you can use as is or modify to your needs. These templates illustrate high quality design principles combined with standards driven code. Each template is XHTML 1.1 Strict, Section 508/WCAG conforming and works across many browsers. This document describes how the template was built, the thought processes, tradeoffs, and workarounds necessary to build them. It also contains instructions on how to easily customize and change these templates for use in your site. You will find these HTML templates to be an excellent starting point when beginning to build out dynamic, data-driven Web sites with Microsoft Visual Studio and Microsoft Visual Web Developer. We hope they'll give both designers and developers deep insight into their creation process while providing you with a workable starting point. You can find all the information you need on MSDN at http://msdn.microsoft.com/asp.net/designer.

Table layouts versus DIV layouts

In the past, developers have used tables to build their page layouts. In many cases it's acceptable to build a layout with tables. However, there are compelling arguments (and laws) that recommend we use tables only when presenting tabular data and use DIV tags and CSS to create our layouts. Because of this there are two versions of each design template; one that uses DIV tags for layout and one that uses tables for layout.

Usability & Accessibility

Summary

Usability is the science of understanding how people use products and software. The information gained from usability studies is used to make the products or software easier to use, more efficient and more productive. Accessibility is a related area of study that focuses on the use of the products or software by people with disabilities.

Why Read this Section?

In some cases accessibility and usability features are required by law. In all cases, good accessibility and usability features make your site easier to use and affect your company's goals. In addition, good accessibility and usability practices help to ensure your content will be accessible to future products that have yet to come to market. This section will not cover all areas of usability and accessibility but will help build an a attitude for best practices and an introduction to the most common usability and accessibility requirements.

Many different kinds of browsers

Before analyzing a site's degree of usability and accessibility we must first look at the different types of browsers people use and the ways users interface with a Web site. Most often Web sites are viewed in a visual browser like Microsoft Internet Explorer running on a desktop PC with a mouse used to click different areas of the page. But there many other browsers and interfaces.

There are non-visual browsers (or technology that "sits on top" of a browser) used by people who are blind that read the contents of your Web page through computer generated voice. JAWS and Window Eyes are two popular non-visual browsers. These kinds of browsers or assistive technology rely on the keyboard alone and do not use a mouse to navigate the pages. There are many other types of input and output devices like braille readers and the Stephen Hawking Device. Many mobile phones now have browsers. Most browsers on phones do not use a mouse and have very small screens. Some mobile phones will render CSS, graphics and multimedia, others do not. There are new browsers and ways of interfacing with Web pages coming to the market every year.

Creating a Web site that is accessible to many different browsers and interfaces require attention to detail that may otherwise be overlooked. The usability and accessibility information below will help you build pages that are accessible to a wide range of audiences and browser types.

Page Titles

One of the most important usability features of a Web page is its title.

The page title in the head of your page is an important usability feature.

<head>
  <title>Your unique and descriptive page title here</title>
</head>
<body>

Make your page titles descriptive and meaningful. Your page titles should describe the content of its particular page. Page titles should not simply state the same thing on multiple unrelated pages. There is no need to start titles with "Welcome.." or "Welcome to my site.." because this does not give detail and meaning to your content. Each page of your site should have a unique, descriptive page title. Well written, unique titles for every page in your site will help in the following ways:

  • well-written page titles help users navigate your site
  • well-written page titles help search engines accurately index your site
  • well-written page titles help identify bookmarks or favorites
  • well-written page titles help non-visual browsers and people who are blind quickly understand the contents of the page

Alternative text and titles for graphics

People using non-visual browsers can not see your graphics (bit map files in the JPEG, GIF or PNG formats). However, non-visual browsers will read the alternative text and titles for each graphic. Creating alternative text for every graphic is fundamental to your site's usability and accessibility. Without well-written and informative alternative text visually impaired users have no way to understand the meaning of your graphics.

The alternative text will also display in visual browsers if the image doe not load. In addition, alternative text helps search engines index your site correctly. Including a title attribute on your graphics further help sighted and non-sighted users understand your graphics.

Alternative text for graphics are set with the ALT attribute inside the IMG tag

 <img src="images/photo-small.jpg" width="150" height="100" alt="Write a short description of the image here. It will show if the image is not loaded. Non visual browsers and search engines will also read this text." title="Users will see this text when they roll over this image. Non-visual browsers will read this text to people who are blind." />

Spacer graphics (1 pixel transparent graphics used in table layouts) are not used in this template. However, if you are forced to use spacer graphics it is the correct usability practice to set an empty ALT text string on them. This tells people using non-visual browsers that the graphic has no meaning. It is incorrect to omit the ALT tag completely since then people using non-visual browsers may wonder if the graphic has meaning or not. Below we correctly set an empty ALT tag on the "spacer" graphic.

<img src="images/spacer.gif" width="10" height="10" alt="" />

Titles are not necessary in the example above.

Browser size and "above the fold"

All the Microsoft Visual Studio Design Templates are made to fit within a 800 pixel wide by 600 pixel tall resolution monitor without the need to scroll horizontally (left - right). Do not force your visitors to scroll horizontally. Doing so will make your site unusable.

The exact width of this template is 760 pixels. We leave 40 pixels of extra room for the display of vertical scrollbars and a small amount of white space so that the horizontal (left - right) scroll bars will not appear on maximized browser windows.

Although vertical scrolling (up - down) is inevitable with any Web page, we can control what initially appears on screen without scrolling down on an 800 pixel by 600 pixel monitor. The content area shown on screen after the page loads but before scrolling down is called "above the fold". This term is taken from the newspaper industry. The most important articles and headlines on a newspaper are shown "above the fold" of newspaper. Web sites too should keep the most important information above the fold. Often times people will not scroll down once a page loads. Therefore, it is important to keep all major navigational menus, main advertisements and other important links and content "above the fold".

Using relative font sizes

There are several ways to specify text sizes with CSS. For this discussion we'll look at two, (1) relative and (2) constant. Text is set to a relative size with the EM or % attribute. Text set to relative sizes can be enlarged or shrunk in most browsers. Text is set to a constant size with the PX or PT attribute. Text set to a constant size are "locked" and can not be resized in most browsers. Although, more modern browsers allow users to change the font size regardless of what attribute is used, its an accessibility best practice to set font sizes using relative attributes (EM or %).

Why should we allow users to change font sizes? It's helpful for people with visually disabilities, since they can make the fonts larger and easier to read.

TIP: You can change the font size of text in Internet Explorer by clicking the "View" menu then "Text size". If your mouse has a scroll wheel you can also hold down the "Control" key while scrolling the scroll wheel on your mouse. Other applications have specific keystroke shortcuts that will change the font size.

Font size example:

The size of this text is set with a relative attribute and can be resized by users. The CSS rule used to set this size is below.

.relative-font-size {
    
font-size: 120%;
     }

The size of this text is set with a constant attribute and can't be resized by users. The CSS rule used to set this size is below.

.constant-font-size {
    
font-size:18px;
     }

Making forms accessible

Fieldset and Legend tags

The FIELDSET tag groups form elements. The LEGEND tag ads a title to the FIELDSET group. The FIELDSET and LEGEND tags clarify their purpose of your form. People using visual and non-visual browsers benefit when you use the FIELDSET and LEGEND tags on all your forms. The FIELDSET tag itself can be styled with CSS the same way any block level element can be styled. As shown in this template you can nest FIELDSETs into sub groups when it will help clarify the purpose of the form and its elements.

FIELDSETs group form elements and LEGENDs add a title to the groups.

Join our mailing list



Below is the simplified source mark-up for this example.

<form>
  <fieldset>
    <legend>Join our mailing list</legend>
      <label for="email">your email</label><br />

      <input name="email" type="text" />
      <label for="postalcode">postal code</label><br />
      <input name="postalcode" type="text" />
      <input type="button" value="join" />
  </fieldset>
</form>

Label tags

The LABEL tag is used to explicitly label an INPUT element. In this template we have a FORM titled "Join our mailing list". In the FORM we have an INPUT field for the user's name. We tie the LABEL tag "your name" to this particular INPUT field by wrapping "your name" in a LABEL tag and then assigning a unique ID to the INPUT tag and LABEL tag.

The LABEL tag is associated to text fields with an ID.

<label for="name">your name</label>
<input id="name" type="text" value="enter your name" />

The LABEL tag can also be associated to radio buttons or checkboxes:

<label for="radioformat1">
<input id="radioformat1" type="radio" />

<label for="check1">
<input id="check1" type="checkbox" />

By explicitly attaching a LABEL tag to the INPUT field we clarify what information is being requested from the user. Non-visual browsers read the LABEL tag for the associated INPUT field regardless if the two tags are adjacent to each other in the source code.

Optgroup tags

The OPTGROUP tag is used to group related options in a SELECT list (drop down menu). Its not often we need to use the OPTGROUP tag. However, if you have a large list in a drop down menu OPTGROUP can greatly improve the clarity and usability of your SELECT lists.

OPTGROUP tags can greatly improve the clarity and usability of large SELECT lists.

<select id="favmag1" name="favmag1" >
  <option value="0" selected="selected">- - Select your favorite magazine - -</option>
  <optgroup label="Computer">
    <option value="1">MSDN</option>
    <option value="2">CODE</option>
    <option value="3">BYTE</option>
  </optgroup>
  <optgroup label="Lifestyle">
    <option value="5">GQ</option>
    <option value="6">Home and Garden</option>
    <option value="7">US</option>
  </optgroup>
  <optgroup label="News">
    <option value="8">Time</option>
    <option value="9">The Week</option>
    <option value="9">People</option>
  </optgroup>
</select>

The code above produces this drop down list.

Do not use graphics to title or label your forms

It may be tempting to use JPEG, GIF or PNG graphics to label FORMs and their elements. However, in most every case, doing so will reduce the usability and accessibility of your forms.

Making tables accessible

Table summary

As explained earlier TABLE tags are used in this layout only when presenting tabular data.

Every TABLE tag should have an accompanying SUMMARY attribute and text that explains the contents and structure of the TABLE for people using non-visual browsers. Users without visual impairment can very quickly scan the contents of a table to get an idea of its meaning and structure. Visually impaired people using non-visual browsers must wait for their non-visual browser to read the Web site contents linearly from start to finish. Well-written TABLE SUMMARY attributes allow people using non-visual browsers to quickly understand the TABLE contents and structure.

TABLE SUMMARY attributes explain the TABLE contents and structure to non-visual browsers.

<table class="table" rules="cols" border="0" cellpadding="0" cellspacing="0" summary="A list of widgets. Each widget is listed by name, price, features and in stock availability.">

Caption

The CAPTOIN attribute for a table will be shown in visual browsers and serves as a title for your TABLE. This caption should be descriptive and clarify the purpose and content of you TABLE.

The CAPTION attributes is the first tag inside the table and serves a title for the table. Both visual and non-visual browsers will see this CAPTION.

<table class="table" rules="cols" border="1" cellpadding="0" cellspacing="0" summary="A list of widgets. Each widget is listed by name, price, features and in stock availability.">
    <caption>
     Widgets currently on sale.
    </caption>
    <tr>
    <td>
    etc...

Acronyms and abbreviations

We shouldn't assume people know the meaning of the acronyms and abbreviations in our content. The ACRONYM and ABBR tags are used to help with this problem. We should wrap all acronyms and abbreviations in the ACRONYM and ABBR tags and to include title attributes in these tags.

You can style these tags so that people using visual browsers will know they are "hot" and look similar to a link. When users hover the mouse over the text wrapped with these tags the cursor changes to a question mark and tool tip text appears with the title you have provided.

Non-visual browsers will read the ACRONYM and ABBR tag title attributes to users instead of trying to read the acronym or abbreviation as a word. For example. If "IRS" is not wrapped in an abbreviation tag and given a title a non-visual browser may read it as a word "urse", as in "purse". When the abbreviation tag and associated title is used a non-visual browser will read "IRS" as: "Internal Revenue Service".

Note that the ABBR tag is only supported in some browsers currently but we should plan on its support in new versions.

The Web site.

The <abbr title="Internal Revenue Service" lang="en">IRS</abbr> Web site.

Breadcrumbs

Breadcrumbs are a list of sequential links that take the user from the current page, back to its parent section(s) and finally to the home page. Breadcrumbs offer a quick and easy way for users to navigate your site and know where they are. It is a good practice to conclude your list of breadcrumbs with a non-linked title of your current page.

Breadcrumbs help to make your site usable.

Home / Breadcrumb link / Breadcrumb link / Page title

Allow non-visual browsers to skip past repetitive navigation links

Non-visual browsers will read the contents of a page linearly from the top down. Many times the first elements to appear in a page are sets of navigation links. It's useful for people using non-visual browsers to be able to skip links that appear on every page versus waiting for their browser to read through them.

To allow users to skip past these repetitive links we add an anchor link above the repetitive content which then links to another named anchor further down the page.

It's a good accessibility practice to add an anchor link before navigation items that repeat on every page which then links to another named anchor further down the page (where the main, unique content for the page content begins). We add the link above the repetitive content like this.  

<div class="none"><a href="#maincontent">skip to the main content area of this page</a></div>

<div id="mainmenu">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Products</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Login</a></li>
    <li><a href="#">Join</a></li>
  </ul>
</div>

Then create a named anchor just before the main, unique content on the page like this:

<a name="maincontent" id="maincontent"></a>
<p>The main body of the page content starts here</p>

Notice in the example above "skip to the main content area of this page" link is wrapped in a DIV with class equals "none". The "none" class below tells visual browsers not to display this DIV. Since non-visual browsers will ignore the CSS styles they will see it.

Hide the "skip to the main content area of this page" link from visual browsers by assigning it a CSS rule set to DISPLAY equals NONE.

.none {
     display:none;
     }

Section 508 conformance

What is Section 508

"Section 508" (as it is often called) is a part of the Rehabilitation Act that requires Federal agencies to make their electronic and information technology accessible to people with disabilities.

Although non-Federal agencies are not required by law to conform to Section 508 guidelines it is commonly understood that web sites that follow many of the Section 508 guidelines are easier to use by all users (with or without disabilities) thus affecting your company's goals.

The Section 508 requirements differ from the Web Content Accessibility Guidelines guidelines (WCAG, below) in that Section 508 looks at all possible forms of electronic and information technology. The WCAG guidelines are written specifically for web authors.

Below is a quote from the Official Web site for Section 508 of the US Rehabilitation Act

In 1998, Congress amended the Rehabilitation Act to require Federal agencies to make their electronic and information technology accessible to people with disabilities. Inaccessible technology interferes with an individual's ability to obtain and use information quickly and easily. Section 508 was enacted to eliminate barriers in information technology, to make available new opportunities for people with disabilities, and to encourage development of technologies that will help achieve these goals. The law applies to all Federal agencies when they develop, procure, maintain, or use electronic and information technology. Under Section 508 (29 U.S.C. ‘ 794d), agencies must give disabled employees and members of the public access to information that is comparable to the access available to others. It is recommended that you review the laws and regulations listed [on our Web site] to further your understanding about Section 508 and how you can support implementation.

Section 508 checklists

All the requirements for Section 508 conformance can be found on the Official Web site for Section 508 of the US Rehabilitation Act. However, it us useful to reference Section 508 conformance checklists that have been created for Web developers specifically.

The information needed to provide a thorough checklist for Section 508 is beyond the scope of this document. But, there are many reliable resources on the Web that provide checklists. Here are a few:

How this template conforms

All the Microsoft Visual Studio Design Templates conform with Section 508 guidelines. However, the design templates are only a single page and do not contain scripts and other functionality that need to be tested against the Section 508 guidelines.

How your code can conform

This documentation lists many of the fundamental Section 508 guidelines needed for the single page design templates to conform. But after modifying the template to meet your needs, adding scripts, new code, multimedia and new content to the template you'll need to further research how your added code can conform.

WCAG, Web Content Accessibility Guidelines

The WCAG, written by the World Wide Web Consortium (W3C) maintains a set of accessibility guidelines for Web content. The WCAG requirements differ from the Section 508 guidelines (above) in that WCAG requirements are written specifically for web authors. Section 508 requirements looks at all possible forms of electronic and information technology, not just the web. WCAG guidelines will help make your web site easy to use.

How good usability helps optimize your site for search engines

Most search engines today base their search results on text that is "read" by robots or programs that scan your site's content. Sometimes these robots are called "bots" or spiders. Each search engine has their own robots that scour the internet for content. In many ways these bots respond to the content on your page the same way that non-visual browsers do. In other words, they respond mainly to well-formed, well written text that is presented logically. For example, above we looked at the CAPTION attribute for tables. The CAPTION is added to your TABLE for accessibility reasons but this CAPTION probably has important keywords in it that a search engine robot will pick up. In this way, the CAPTION may help people find your TABLE data. All search engine robots place a lot of importance on your page titles. Well written, informative page titles that do not contain unnecessary information will help your page's accessibility, but they also can help your search engine results.

Here's another example. Keywords that appear in the top part of your page can get a higher degree of importance from search engine robots. We've talked about keeping important information "above the fold" for accessibility reasons. But also, keeping important information and important keywords "above the fold" can help your page's rank in search engine results.

Let's look at another example before we move on. Not all content can be communicated with text. We often use images to communicate ideas, charts, graphs, product images, logos, etc.. Although search engine robots can not determine the content of graphic images, they will read and rank the ALT attribute for an image. Again, the ALT attribute is not only a fundamental accessibility feature, it can help your content get placed appropriately in search engine results.

Accessibility resources

There are several free accessibility validators on the Web that you can send your pages through. These validators will generate a report that displays your pages's degree of accessibility. These tools are very useful, but can never be 100% accurate. They will expose many of the most common usability problems with your site, but it will also be up to you to fully understand the concepts of the Section 508 requirement, WCAG guidelines, accessibility and usability best practices in order to make your site compliant. Again, making your web site accessible increases the ease of use of your site for all visitors and can affect your company's goals.

  • Bobby is a great, free tool that will help you identify accessibility deficiencies in your site.
  • The AIS Web Accessibility Toolbar can help you test the usability of your site by allowing you to manually examine your pages for accessibility deficiencies.
  • Visual Studio 2005 also includes a built-in accessibility checker to help make Section 508/WCAG conformance easier.

HTML Mark-Up

XHTML strict doctype

XHTML is a combination of HTML and XML. There are three DOCTYPEs that can be used with XHTML files, (1) strict, (2) transitional and (3) frameset. The DOCTYPE tells the browser to render the page in a particular way. The XHTML strict DOCTYPE is less forgiving than the transitional DOCTYPE.

Although XHTML strict can use most HTML 4.0 tags and syntax, some of the HTML 4.0 tags and nesting of tags that are valid in HTML 4.0 are not valid in XHTML.

Valid XHTML strict code also separates the content from the layout and style. That is, with XHTML strict it is not valid to include style information (font size, color, width, heights, positions, etc.) inside the source mark-up. Instead, all styles must be linked to a separate CSS file. The W3C owns The official XHTML specification.

The Microsoft Visual Web Developer Design Templates use the strict DOCTYPE. This DOCTYPE is added to the top of the page code.

The DOCTYPE is the first thing shown in your code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

Why use XHTML Strict?

XHTML strict pages are accessible to a broader range of viewing devices currently in the marketplace. Code used in XHTML strict pages have a longer life of relevance with products that have yet to come to market. XHTML will eventually replace HTML 4.0 as the standard. Lastly, pages that use the XHTML strict DOCTYPE require your code to be more accurate, more efficient and clean (no missing end tags).

Adding the favicon.ico to your header

A favicon is a 16 by 16 pixel graphic that most modern browsers will show as the icon for your site. This icon appears in the address field, bookmark list and links bar of most browsers.

Each Microsoft Visual Web Developer Design Template comes with a file called favicon.ico that can be found in the images folder for each template. These icons match the default look of the template. In order to display this icon in the browser you link to it in the HEAD of your XHTML file.

To display the favorite icon link it in the HEAD of your XHTML.

<head>
<title>div - rounded</title>
<link rel="shortcut icon" href="images/favicon.ico" />
</head>

There are several resources on the Web that can help you make your own favicon.ico files.

Keeping styles out of the HTML mark-up

With HTML you were able to style your content inline with the source mark-up. As mentioned earlier, the XHTML strict doctype does not allow style information inside your XHTML. Instead, all styles must be linked to a separate CSS file. Separating the styles from the content has these advantages:

  • Separating visual style from content gives you more style and layout options since CSS has greater style options than HTML inline styling.
  • Separating visual style from content increases your ability to keep styles consistent across many pages.
  • Separating visual style from content allows you to change the styles on every page in your site by changing only one CSS file.
  • Separating visual style from content makes your pages load faster since the styles (the CSS document) are only downloaded once for any page in your site.
  • Separating visual style from content makes your site more accessible and usable since people using browsers that do not support styles will still have access to all your content, but simply no style information.

Using DIVs for layout

See creating the layout with DIVs.

Heading tags (used to build an outline, not to make fonts larger)

Your heading tags (H1, H2, H3, H4, H5 and H6) should build a logical outline of your content. Building an outline of your content with heading tags will help improve the clarity of your content for all users. People using non-visual browsers can instruct their browser to only read the heading tags on your page. This allows all users to quickly understand your page contents.

Remember, non-visual browsers read all the text to users through computer voice synthesis. If there are no headings or incorrectly used heading tags these users are forced to listen to all the text read linearly from top down. In other words, heading tags help non-visual browsers scan a page.

Do not use heading tags to make a FONT bold or larger. Use CSS to style text.

You can easily change the default style (FONT-SIZE, FONT-WEIGHT, COLOR, etc.) of all heading tags through CSS.

Use heading tags to build a logical outline of your content.

<h1>site name</h1>

  <h2>page title</h2>

   <h3>section title</h3>
    <p>Summary paragraph of the section goes here.</p>

    <h4>sub section heading one </h4>
   
<p>Sub section one paragraph text goes here.</p>

    <h4>sub section heading two</h4>
    <p>Sub section two paragraph text goes here.</p>

    <h4>sub section heading three </h4>
    <p>Sub section three paragraph text goes here.</p>

  <h3>section title</h3>
  <p>Summary paragraph of the section goes here.</p>

  <h3>section title</h3>
  <p>Summary paragraph of the section goes here.</p>

Forms

See Making forms accessible

Showing data in tables

As explained earlier tables are used in this layout only when presenting tabular data.

The table header, footer and body

The THEAD, TFOOT and TBODY tags group the sections in your TABLEs. The THEAD should come first in your source, then the TFOOT then the TBODY. The footer comes before the body in the source so the browser can render it before the contents of the entire table body are downloaded. In addition, if the contents of a TABLE span multiple pages when printing the THEAD and TFOOT will be printed on each page.

The table header, table footer and table body tags group sections of your TABLE.

<table>
  <thead>
    <tr>
    <th>Table Header</th>
    </tr>
  </thead>
  <tfoot>
    <tr>
    <th>Table Footer</th>
    </tr>
  </tfoot>
  <tbody>
    <tr>
    <td>Table Body</td>
    </tr>
  </tbody>
</table>

Colgroup tags

See styling COLGROUP tags with CSS.

Targeted browsers

The Microsoft Visual Web Developer Design Templates are designed to work in the following browsers. Modifications and added code to the templates will require additional testing on your targeted browsers. Each browser's support for CSS and XHTML strict vary. It is a good idea to have a clear list of the browsers you intend to support before your projects begin.

  • Microsoft Windows XP
    • Internet Explorer 6
    • Mozilla Firefox 1
  • Microsoft Windows 2000
    • Internet Explorer 6
    • Mozilla Firefox 1
  • Apple Macintosh OSX
    • Internet Explorer 6
    • Mozilla Firefox 1.0.1
    • Safari 1.2.4

Cascading Style Sheets

CSS is a style sheet programming language that allows you to attach style (color, fonts and layout) to structural documents (HTML, XHTML). Authoring, viewing and maintaining Web sites is simplified by separating the style from the content.

Cascading style sheets are powerful and can be quite in-depth. This documentation will touch on the basic principles of CSS. The Official CSS 1 Specification contains much more detailed information and is a valuable resource.

Why CSS

See Keeping styles out of the HTML mark-up.

What is a CSS rule

A CSS rule is made up of selectors, properties and values. Selectors tell the browser which items on your page to style. Properties identify the type of style you want to apply. Values set the style.

In the example below "H1" is the selector, "COLOR" is the property and "black" is the value.

A CSS rule is made up of selectors, properties and values.

h1 {
     color: black;
    
}

The example below is the same as the example above since "#000000" is the hex color value for black.

h1 {
     color: #000000;
     }

CSS selectors (classes, id's or HTML tags)

A selector can be a class, an ID, an HTML tag or a combination of many of these.

The difference between classes and IDs.

Classes can appear several times within a single XHTML (or HTML) document. There can only be one instance of an ID in each page.

HTML tags as a CSS selectors

You can apply CSS styles to HTML tags. For example, in XHTML strict pages it is not valid to add MARGINTOP="0" in the BODY tag. So, instead, apply this margin style in your CSS document with "BODY" as a selector.

You can use an HTML tag as a selector. In this case "BODY" is the CSS selector.

body {
     margin-top: 0px;
     }

If you wanted to make the entire page use a gray, sans-serif font you can use the BODY tag as the selector and then apply styles to it. Notice that each property and value set must be separated by a semi-colon (;).

body {
     color:#999999;
     font-family:sans-serif;
    
}

IDs as CSS selectors

If you're styling an element that only appears once in your source mark-up you can apply an ID to your element then style the ID in your CSS file. For example, if you have only one main menu DIV in your source mark-up then you can apply an ID to this DIV then style the ID in your CSS file.

IDs only can only appear once in your source mark-up. In the mark-up you identify the element by assigning it an ID.

<div id="mainmenu">Home Products Services</div>

Then, you can style this ID in your CSS file by using the ID name as the selector in your CSS file. You signify that a selector is an ID with the pound sign (#). There can be no spaces between the pound sign and the selector name.

#mainmenu {
    position:absolute;
    top:10px;
    left:10px;

    color:#FF0000;
    font-weight:bold;
    }

The example above absolute positions the main menu DIV ten pixels from the top of the browser and ten pixels to the left.

Classes as CSS selectors

If you're styling an element that appears more than once in your source mark-up apply a class to it. For example, if you have many separate strings of text that need to be small you can assign a class to each occurrence of this small text in your mark-up then style the class in your CSS file.

Classes can appear many times in your source mark-up. In the mark-up you identify the element by assigning it a class.

<p class="small-text">This text will be small</p>
<p>Some more text here</p>
<p class="small-text">And more small text here</p>

Then, you can style this class in your CSS file by using the class name as the selector in your CSS file. You signify that a selector is class with a period (.). There can be no spaces between the period and the selector name.

.small-text {
     font-size:.7em;
     }

Class and ID naming guidelines

Class and ID names can contain only alphanumeric characters and the hyphen (-).

Do not name your classes or IDs by the style or layout they produce. For example, do not name a class or ID "redtext" since you may easily change the style of this element to use blue text down the road. The name will then have little meaning and will be confusing. You could instead name this element "productname" or "requiredtext" or "importanttext".

Links & pseudo classes (link, hover, active, visited)

Browsers display visited and non-visited links differently to users so they can see what links they have visited and what links they have not. There are two special CSS classes, called pseudo classes, that allow you to control how visited and non-visited links are styled.

":LINK" is a pseudo class that controls the appearance of non-visited links. ":VISITED" is a pseudo class that controls the appearance of visited links.

Including the following two rules in your CSS file will make all non-visited links red and all visited links orange.

":LINK" is a pseudo class that controls the appearance of non-visited links. 

a:link {
     color: red;
     }

":VISITED" is a pseudo class that controls the appearance of visited links. 

a:visited {
     color: orange;
    
}

There are two more dynamic pseudo classes that control the appearance of items that are hovered (by a pointing device, typically a mouse pointer) and activated.

":HOVER" is a pseudo class that controls the appearance of hovered links. ":ACTIVE" is a pseudo class that controls the appearance of activated links.

To have complete control over the appearance of your links use all four pseudo-classes in your CSS document.

To work properly the following four rules must be written in this order (LINK, VISITED, HOVER and ACTIVE).

a:link {
     color:blue;
     text-decoration:underline;
     }

a:visited {
     color:purple;
     }

a:hover {
     color:red;
     text-decoration:none;
     }

a:active {
     color:green;
     }

Heading tags

As mentioned in the accessibility section its important to use headings to build an outline of your page content. It's wrong to use headings solely to change the font size or weight of text.

You'll probably want to change the default appearance of your headings after you build your outline. To do this, simply use the heading tags as selectors in your CSS file and make them the size and style you prefer.

To style your heading tags use the H1, H2, H3, H4, H5 and H6 tags as selectors then apply styles to them.

h1, h2, h3, h4, h5, h6 {
     color:red;
     font-variant: small-caps;
     }

Form tags

See Making forms accessible.

Lists as menus (horizontal or vertical)

Ordered and unordered lists (the OL tag and the UL tag respectively) are appropriately used to make navigational menus. Create the menu as a list in the source mark-up then style the list layout and appearance with CSS. CSS can turn lists into a horizontal menu (top menu) or vertical menu (side menu). With CSS we can add padding, margin, background color, etc. to your menu items with great control. Here are some benefits of making navigational menus from lists rather than tables or other means.

  • Navigational menus made from lists produce cleaner more efficient source mark-up.
  • Navigational menus made from lists are more accessible to people with disabilities compared to navigational menus made with TABLE tags.
  • Navigational menus made from lists produce a more predictable and usable display when viewed without style sheets than navigational menus built with TABLE tags.
  • Maintaining a navigational menu made from a list is fast and easy since all the visual control and layout of the menu is maintained through a single CSS file. The source mark-up does not need to change.

It is clean and efficient to make navigation menus from ordered and unordered lists. Here is a simple navigation list without styles.

<div id="mainmenu">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Products</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Login</a></li>
    <li><a href="#">Join</a></li>
  </ul>
</div>

The source markup above produces this list.

 

We take this same source mark-up and make horizontal navigation menu with it using CSS.

<div id="mainmenu">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Products</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Login</a></li>
    <li><a href="#">Join</a></li>
  </ul>
</div>

By adding these three CSS rules to our CSS file we turn the list above into a horizontal navigation menu.

#mainmenu ul {
     margin:0px;
     padding:0px;
     }
#mainmenu ul li{
     list-style:none;
     display:inline;
     text-transform:uppercase;
     font-size:.8em;
     margin:0px;
     padding:1px 10px;
     background: #CCCCCC;
     }
#mainmenu ul a:link {
     text-decoration:none;
     }

The three CSS rules above produce this navigation menu. The source mark-up for both examples are exactly the same.

Or by using these three CSS rules we turn the list above into a vertical navigation menu.

#mainmenu-vertical ul {
     margin:0px;
     padding:0px;
     }
#mainmenu-vertical ul li{
     list-style:none;
     display:inline;
     text-transform:uppercase;
     font-size:.8em;
     margin:0px;
     padding:1px 10px;
     background: #CCCCCC;
     }
#mainmenu-vertical ul a:link {
     text-decoration:none;
     }

You'll notice that each of the three CSS rules above start with the "#mainmenu" or "#mainmenu-vertical" DIV ID. If this DIV ID was not used in the selector every UL tag on all of your pages would be styled the same way as the main menu. Therefore, it's important to target the specific lists you want to style by first targeting its containing element. In this case the container was the "#mainmenu" or "#mainmenu-vertical" DIV.

In this template you'll find two different types of list styles.

  1. #content (the main content area)
  2. #side (the side menu area)

Specifying font families

See Font families.

Creating the layout with DIVs

What is a DIV?

DIV is short for division or section. The DIV tag is a generic or empty block level element that defines a section of the document. A DIV starts with the opening DIV tag, <DIV> and ends with the closing DIV tag </DIV>.

Visual browsers add a line break before and after all block level elements. As apposed to a SPAN tag (also an empty container tag) except that line breaks are not added before and after a SPAN tag. Some other block level HTML tags include the P tag, the heading tags H1, H2, H3, H4, H5 and H6, the BODY tag and others.

DIV tags are often viewed as rectangle blocks that hold a section of content. By applying CSS classes or a unique ID to DIV tags we can control the visual appearance of the DIV itself and the content contained in the DIV.

DIV tags can be styled with CSS. We can also target the content inside the DIV to be styled. Here is a DIV with a white background and red text inside.

This red text is inside a white DIV

Here is the CSS that creates this look.

.your-class-name{
     background:#FFFFFF;
     color:red;
     }

Here is the source mark-up.

<div class="your-class-name">This red text is inside a white div</div>

 

The DIV below also has a width set to it and only the heading two tag is red.

This heading tag is red

This text is the default color

The two CSS rules below create this look.

.your-class-name{
     background:#FFFFFF;
     width:200px;
     }

.your-class-name h2{
     color:red;
     }

Here is the source mark-up.

<div class="your-class-name">
  <h2>This heading tag is red</h2>
  This text is the default color
</div>

 

The DIV below has a width set to it, it has a border and it has another DIV inside it.

This heading tag is red

This text is the default color.
This text is white and centered with a green background

The three CSS rules below create this look.

.your-class-name{
     background:#FFFFFF;
     width:200px;
     }

.your-class-name h2{
     color:red;
     }

.another-class-name {
     text-align:center;
     background:green;
     color:white;
     }

Here is the source mark-up.

<div class="your-class-name">
  <h2>This heading tag is red</h2>
  This text is the default color.
  <div class="another-class-name">This text is white and centered with a green background
</div>
</div>

How padding, margin and width work on DIVs

The margin is the blank space outside the DIV (or any block level element it's applied to).

The padding is the blank space inside a DIV.

The complete physical size of a DIV is its width plus margin plus padding.

This DIV has no margin and no padding.

Here is CSS rule for the DIV above:

.your-class-name {
     width:250px;
     background:white;
     }

 

This DIV has a 100 pixel left margin and no padding.

Here is CSS rule for the DIV above:

.your-class-name {
     width:250px;
     background:white;
     margin-left:100px;

     }

 

This DIV has a 100 pixel left margin and a 30 pixel padding.

Here is CSS rule for the DIV above:

.your-class-name {
     width:250px;
     background:white;
     margin-left:100px;
     padding:30px;
     }

 

This DIV has a 100 pixel left margin, 30 pixel padding and a dashed black border.

Here is CSS rule for the DIV above:

.your-class-name {
     width:250px;
     background:white;
     margin-left:100px;
     padding:30px
     border:1px dashed #000000;
     }

CSS shorthand

You can set the top, right, bottom and left PADDING or MARGIN as separate CSS attributes or you can use CSS shorthand to set them all within one attribute. CSS shorthand uses less lines of code thus it loads faster and is faster to write and edit.

This CSS rule ...

.your-class-name {
     padding-top:10px;
     padding-right:0px;
     padding-bottom:5px;
     padding-left:22px;
     }

... produces the same results as this CSS rule:

.your-class-name {
     padding:10px 0px 5px 22px;
     }

Floating DIVs

The CSS attribute FLOAT makes a DIV (or other block level elements such as an IMG) align to the right or left of its containing element. FLOAT is a necessary and fundamental attribute in many types of layouts.

Always set a width on a DIV that is floated. If no width is set the results are unpredictable.

This DIV is set to float right. It uses this CSS rule:

.your-class-name {
     width:45%;
     background:white;
     float:right;

     }

Using container DIVs and the CSS clear attribute

Due to the nature of "floated" DIVs it is often necessary to put them within a container DIV.

The example below uses three DIVs. There is a dark gray container DIV and two other DIVs that float left and right.

This is the container DIV. It uses this CSS rule:

.your-class-name-container {
     background-color:#999999;
     padding:10px;
     }

This DIV is set to float left. It uses this CSS rule:

.your-class-name1 {
     width:45%;
     background:white;
     float:left;

     }

This DIV is set to float right. It uses this CSS rule:

.your-class-name2 {
     width:45%;
     background:white;
     float:right;

     }

 

Although the gray container DIV completely surrounds the two white floated DIVs in the source mark-up the DIV does not expand down along with the white DIVs because they are both floated.

The example above uses this simplified source mark-up.

<div class="your-class-name-container">
  <div class="your-class-name1"></div>
  <div class="your-class-name2"></div>
</div>

 

In the previous example the gray container DIV does not expand down along with the white floated DIVs. By adding a fourth DIV set to CSS "clear:both" and putting this DIV as the last DIV inside the container we can force the container DIV to expand down with the white floated DIVs.

This is the container DIV. It uses this CSS rule:

.your-class-name-container {
     background-color:#999999;
     padding:10px;
     }

This DIV is set to float left. It uses this CSS rule:

.your-class-name1 {
     width:45%;
     background:white;
     float:right;

     }

This DIV is set to float right. It uses this CSS rule:

.your-class-name2 {
     width:45%;
     background:white;
     float:right;

     }

 

The example above uses this abstracted source mark-up:

<div class="your-class-name-container">
  <div class="your-class-name1"></div>
  <div class="your-class-name2"></div>
  <div style="clear:both"></div>
</div>

The CSS CLEAR attribute controls weather or not a nearby element will appear on the same line as a float or after a float. See The Official CSS Specification for the CLEAR Property.

For the purposes of this documentation we look at the basic examples of floating DIVs left and right and "clearing" a container DIV. There are many more complexities in the way different browsers render floated elements. However, each of the five Microsoft Visual Web Developer Templates provides several unique examples and strategies for different layout types, from two or three column layouts to fixed width and variable width layouts.

The 5 layout types included in the Microsoft Visual Studio Design Templates

Each of the 5 Microsoft Visual Studio design templates uses a different layout type, different CSS and different mark-up strategy. The list below is a quick reference for these layouts types.

The Rounded template
  • 2 column layout
  • Both columns are fixed width
The Simple template
  • 3 column layout
  • The side columns are fixed width. The middle column is "stretchy"
The Grid template
  • 3 column layout is used in the header section
  • 2 column layout is used for the body section
  • All the columns are "stretchy"
The Fun template
  • 2 column layout
  • Both columns are "stretchy"
  • This layout uses absolute positioning
The Basic template
  • 2 column layout
  • Both columns are fixed width

How to create this template's two column "stretchy" layout with DIVs and CSS

The header area of this layout is made with two DIVs and CSS.

The header area is made with two DIVs. A container DIV for the logo text and a DIV that holds the site name and slogan.

<div id="logotext">{s}</div>
<div id="sitename">
     <h1>site name goes here</h1>
     <h2>slogan goes here</h2>
</div>

Then using the CSS below we tell these DIVs where to live, what color to be, how wide and tall to be, etc.

First, we set the styles on the "logo text" container DIV. Notice that this DIV is absolute positioned. Whenever a DIV is absolute positioned you must also specify the TOP (or BOTTOM) and LEFT (or RIGHT) attributes. When a DIV is absolute positioned it is taken out of the normal "flow" of the document and will be positioned in relation to it's parent container. In this case the parent container is the BODY.

Normally we set FONT-SIZE to a relative size for accessibility reasons. However, below we set the FONT-SIZE to a static 70 pixels since we do not want the logo text to change size.

#logotext {
     font-size:70px;
     position:absolute;
     top:5px;
     right:50px;
     text-align:right;
     color:#FFFFFF;
     font-weight:bold;
     }

Then, we set the styles on the "site name" container DIV. This DIV also uses absolute positioning. And has a TOP and RIGHT setting.

#sitename {
     position:absolute;
     top:30px;
     right:150px;
     text-align:right;
     color:#FFFFFF;
     }

Next we create the side navigation area with 9 DIVs and some very tricky CSS.

Notice that the two images below have a width set to 100% so that they scale horizontally as their container DIV scales horizontally. The rest of the graphic images in this area are set as background images in the various DIVs.

<div id="side-container-outer">
     <div id="block-side-top-right"><img src="images/block-side-top-right.gif" alt="" width="100%" height="25" /></div>
     <div id="block-side-top-left"></div>
     <div class="clear"></div>
     <div id="side-container-inner">
         <div id="side">
             <div class="clear"></div>
             nav items here
         </div>
         <div>
             <div id="block-side-bottom-right"><img src="images/block-side-bottom-right.gif" alt="" width="100%" height="25" /></div>
            <div id="block-side-bottom-left"></div>
         </div>
     </div>
</div>

Then we set the styles for these DIVs above.

This first rule sets the placement and width for this column. Notice that this DIV is absolute positioned. Whenever a DIV is absolute positioned you must also specify the TOP (or BOTTOM) and LEFT (or RIGHT) attributes. When a DIV is absolute positioned it is taken out of the normal "flow" of the document and will be positioned in relation to it's parent container. In this case the parent container is the BODY.

#side-container-outer {
     width:20%;
     position:absolute;
     top:120px;
     left:0px;
     padding-bottom:100px;
     }

This next DIV is floated right and holds the 100% wide image. Notice that this rule and the rule below add up to 100% width.

#block-side-top-right {
     width:92%;
     height:25px;
     float:right;
     }

The next DIV is floated left and uses a background image. Notice that this rule and the rule above add up to 100% width.

#block-side-top-left {
     width:8%;
     height:25px;
     float:left;
     background: url(images/block-side-top-left.gif) no-repeat top right;
     }

This next DIV is used to set a background color and hold the inner DIVs of this area. The "#929E8E" color is the gray that shows through on the left side of this area.

#side-container-inner{
     background: #929E8E;
     margin:0px;
     padding:0px;
     }

This DIV holds the main navigation. Notice that the WIDTH, plus left MARGIN, plus LEFT and RIGHT padding add up to 100% (70% + 8% + 12% + 10% = 100%). See CSS shorthand to learn how to set top, right, bottom and left PADDING in a single attribute. Using shorthand reduces the lines of code in your CSS.

#side {
     background: #FFFFFF;
     width:70%;
     margin-left:8%;
     padding:0 12% 10px 10%;
     }

This next DIV is floated left and uses a background image. Notice that this rule and the rule below add up to 100% width.

#block-side-bottom-left {
     width:8%;
     height:25px;
     float:left;
     background: url(images/block-side-bottom-left.gif) no-repeat bottom right;
     margin:0px;
     padding:0px;
     }

This next DIV is floated right and holds the 100% wide image. Notice that this rule and the rule above add up to 100% width.

#block-side-bottom-right {
     width:92%;
     height:25px;
     float:right;
     margin:0px;
     padding:0px;
     }

There are also two places in this block of markup that "cleared" DIVs are used. See using container DIVs and the CLEAR attribute.

.clear {
     clear:both;
     }

The content div on the right side of the page is set up the exact same way as the navigation area above (except its horizontally reversed).

Inside the main content area there is a three column section. This section uses 4 DIVs and some tricky and CSS.

The three column section within the main content area is built with 4 DIVs and some tricky and CSS. Notice that the third column appears before the third column in the mark up below.

<div id="three-column-container">
     <div id="three-column-left">first column content</div>
     <div id="three-column-right">third column content</div>
     <div id="three-column-middle">second column content</div>
     <div class="clear"></div>
</div>

Then using CSS we tell the these four DIVs where to live, how wide and tall to be, etc.

First we set the width and margin on the container. The top and bottom MARGIN is set to 10 pixels. The left and right margin is set to 0.

#three-column-container {
     width:100%;
     margin:10px 0px;
     padding:10px 0px;
     }

We then "float" the left column and set it's width to 30%. "Floated" elements should always be accompanied by a width. See floating divs for more information.

#three-column-left {
     float:left;
     width:30%
     }

Next we "float" the left column and set it's width to 30%.

#three-column-right {
     float:right;
     width:30%
     }

Lastly, we make room for the floated DIVs on both sides by setting the left and right margin on the middle DIV. If we didn't add this margin to the middle DIV then it would overlap with the "floats".

#three-column-middle {
     width:30%;
     margin:0px 32% 0px 35%
     }

Background images

Summary

CSS allows you to set the background image (JPEG, GIF or PNG files) on most HTML tags. It is common to use background images on DIV tags, list items, the BODY tag and other elements to archive a certain visual layout.

This template uses background images on the BODY tag and on several DIVs. Below is a simplified version of the CSS code that applies the background to each element.

body {
     background:#5F7558 url(images/bg-main.gif);
     }

#block-content-top-right {
     background: url(images/block-content-top-right.gif) no-repeat;
     }

#block-content-bottom-right {
     background: url(images/block-content-bottom-right.gif) no-repeat bottom left;
     }

#block-side-top-left {
     background: url(images/block-side-top-left.gif) no-repeat top right;
     }

#block-side-bottom-left {
     background: url(images/block-side-bottom-left.gif) no-repeat bottom right;
     }

Include a background color along with the background image

Note that there is also a hex color value listed in the BODY background value. It's a good idea to include a hex color that approximates the color of the background image. In case the image does not load you will still be certain that your general color palette is maintained and the text in this area will still be readable. If a hex color value is not set and the background graphic does not load or is not yet downloaded you may end up with white text and a white background that is unreadable.

Specifying the repeat value x, y or none

In the example above the repeat-x value is also given. This value indicates the background graphic should repeat horizontally.

Using the repeat-y value indicates the background graphic should repeat vertically.

Using the repeat-none value indicates the background graphic should not repeat.

Not specifying a repeat value will cause the background image to repeat both horizontally and vertically.

Specifying the horizontal position value right, left, center or amount

If you do not want the graphic to repeat horizontally you may want to align the background graphic to the right, left, center or position the background graphic by a left offset amount.

This background graphic will align itself to the left of its container and not repeat.

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) no-repeat left;
     }

This background graphic will align itself to the center of its container and will repeat vertically (y).

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) repeat-y center;
     }

This background graphic will align itself to the right of its container and not repeat.

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) no-repeat right;
     }

This background graphic will align itself offset from the left of its container by 25% of the container's width and will repeat vertically (y).

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) repeat-y 25%;
     }

Specifying the vertical position top, center, bottom or amount

If you do not want the graphic to repeat vertically you may want to align the background graphic to the top, center, bottom or position the background graphic by a top offset amount.

This background graphic will align itself to the top of its container and not repeat.

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) no-repeat top;
     }

This background graphic will align itself to the center of its container and will repeat horizontally (x).

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) repeat-x center;
     }

This background graphic will align itself to the bottom of its container and not repeat.

#your-element {
     background: #828AD0 url(images/your-graphic.jpg) no-repeat bottom;
     }

Colgroup tags

Styling a table through the COLGROUP and COL tags is more efficient than styling each individual TABLE cell. To style your tables with the COLGROUP tag you must first add them to your table in your source mark-up.

The COLGROUP tag (combined with THEAD, TFOOT, TBODY and TABLE rows) allow us to style a table much more efficiently than styling each table cell. Here is the source mark-up for a simple two column, two row TABLE.

<table class="table" border="1" cellspacing="0" >
<colgroup>
  <col class="table-column-1" />
  <col class="table-column-2" />
</colgroup>
<tbody>
  <tr class="table-row-1">
    <td>Super widget</td>
    <td>$30.00</td>
  </tr>
  <tr class="table-row-2">
    <td>Mega widget</td>
    <td>$25.00</td>
  </tr>
</tbody>
</table>

Instead of styling each TABLE cell we style the column groups and the rows below.

It's important to note that the BORDER-COLLAPSE property be set to COLLAPSE in the TABLE if you would like to create single pixels borders on the TABLE cells. When this COLLAPSE attribute is set adjacent TABLE elements will have their borders merged.

.table {
     width:40%;
     border-collapse:collapse;
     border:1px solid gray;

     }

.table-row-1 td, .table-row-2 td {
     padding:2px 6px;
     border:1px solid gray;
     }

.table-row-2 td {
     background-color:#FFFFCC;
     color:red;
     }

.table-column-1{
     text-align:left;
     width:65%;
     color:black;
     }

.table-column-2{
     text-align:center;
     width:35%;
     color:red;
     }

The source mark-up and CSS above produce a table like this.

Super widget $30.00
Mega widget $25.00

If your table had many columns or rows, say 20 or 30 of them you can see that using the COLGROUP and COL tags become much more efficient than styling each table cell. More detailed information on column groups can be found in The Official W3C Table Specification.

Validating your pages

Summary

As mentioned earlier the XHTML strict doctype is not forgiving. Your source mark-up needs to be well-structured and free of errors. Because of this it is helpful to run your pages through a validator that checks for errors and offers solutions and explanations for errors it finds. CSS is generally more forgiving but it is also helpful to run your CSS file through a CSS validator.

HTML validation

Microsoft Visual Studio and many other desktop applications contain XHTML strict validators. You can also find many free on line validators. The W3C, is the organization responsible to the official XHTML strict specification. The W3C has a free XHTML validator.

CSS validation

Microsoft Visual Studio and many other desktop applications contain