Open Publish - From tables to full CSS

Next

1 - Aims of this workshop

Take an existing table based layout and:

Open Publish - From tables to full CSS

Next

2 - The existing layout

Open Publish - From tables to full CSS

Next

3 - Existing layout - invalid code issues

Open Publish - From tables to full CSS

Next

4 - What is valid code

Validation is a process of checking your documents against a formal standard, like those published by the W3C. A document that has been checked and passed is considered valid.

Open Publish - From tables to full CSS

Next

5 - Adding a doctype

Open Publish - From tables to full CSS

Next

6 - The doctypes

HTML 4.01 Strict

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Open Publish - From tables to full CSS

Next

7 - Doctypes - Standards compliant (or strict) and quirks modes

Most browsers run in two modes: quirks mode for the old rules and strict mode for the standard. Mozilla, Safari, Opera, Mac/Explorer, Windows/Explorer 6 implemented these two modes. Windows/Explorer 5 and older browsers like Netscape 4, are permanently locked in quirks mode.

There are some very important reasons to use strict, or standards compliant mode. For example, Windows/Explorer 6 will use the correct box model when in strict mode, but the incorrect box model when in quirks mode. Also, many modern browsers will not allow fonts to be inherited when in quirks mode.

Open Publish - From tables to full CSS

Next

8 - Adding character encoding

A character encoding tells the browser which glyph is associated with which character in the HTML code.

<meta http-equiv="content-type" content="text/html; charset=utf-8">

Open Publish - From tables to full CSS

Next

9 - Existing layout - presentation issues

Presentation within markup

Inline images

<img name="nav01" src="site/nav01.gif" width="150" height="24" border="0"></a>

Colors

text="#003366" link="#003399" alink="#CC0000" vlink="#660000"

Widths

<td width="10">

Background colors

<tr valign="top" bgcolor="#FFFFFF">

Next

Open Publish - From tables to full CSS

Next

10 - Existing layout - semantic markup issues

Semantically markup is about using html elements to give content meaning. This is important for a wide range of user agents (browsers without style sheets, text browsers, PDAs, search engines etc.)

Missing heading elements

<font size="4" face="arial, helvetica"><b>Welcome to Company Name</b></font>

Images for content

<img name="nav01" src="site/nav01.gif" width="150" height="24" border="0">

Tables for layout

<table border="0" cellpadding="0" cellspacing="0" width="700" align="center" bgcolor="#FFFFFF">>

Open Publish - From tables to full CSS

Next

11 - Existing layout - accessibility issues

Accessibility issues with existing layout include:

Missing alt attributes

<img name="nav01" src="site/nav01.gif" width="150" height="24" border="0">

Tables for layout

<table border="0" cellpadding="0" cellspacing="0" width="700" align="center" bgcolor="#FFFFFF">>

Images for content

<img name="nav01" src="site/nav01.gif" width="150" height="24" border="0">

Open Publish - From tables to full CSS

Next

12 - Creating new containers

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Company Name</title>
</head>
<body>
<div id="container">
<h1></h1>
<div id="nav"></div>
<div id="content"></div>
<div id="footer"></div>
</div>

</body>
</html>

Open Publish - From tables to full CSS

Next

13 - Adding structurally marked up content into the containers

<h1>
<em>Company Name</em>
</h1>

<h2>
Welcome to Company Name
</h2>

<blockquote>
<p>
"I wouldn't use this company if...
</p>
</blockquote>

Link to example 2

Open Publish - From tables to full CSS

Next

14 - Why use an HTML list for navigation instead of images?

At its most basic level, site navigation is simply a list of links to other pages in the site. So, a standard HTML list is the ideal starting point.

<div id="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">Company</a></li>
<li><a href="#">People</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Shoe fitting</a></li>
<li><a href="#">Rocket design</a></li>
<li><a href="#">Car radios</a></li>
</ul>
</li>
<li><a href="#">Sales</a></li>
<li><a href="#">Awards</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>

Open Publish - From tables to full CSS

Next

15 - Setting up the CSS in the head of the document

This CSS will eventually be moved to a separate file. However, during the initial set up, it is sometimes easier to have CSS and HTML in one file.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Company Name</title>
<style type="text/css">

</style>

</head>

Open Publish - From tables to full CSS

Next

Note - Rule Set structure

Open Publish - From tables to full CSS

Next

16 - Styling the body element

body
{
margin: 0;
padding: 0;
font: 80% arial, helvetica, sans-serif;
background: #3F5D7E;
text-align: center;
}

Link to example 3

Open Publish - From tables to full CSS

Next

17 - Styling the container

#container
{
width: 680px;
margin: 10px auto;
background: #fff;
padding: 10px;
text-align: left;
}

Link to example 4

Open Publish - From tables to full CSS

Next

18 - Styling the header

h1
{
height: 130px;
background: url(site/header.gif) no-repeat;
margin: 0 0 10px 0;
padding: 0;
}

h1 em
{
position: absolute;
left: -2000px;
width: 1800px;
}

Link to example 5

Open Publish - From tables to full CSS

Next

19 - Styling the nav

#nav
{
float: left;
width: 150px;
padding-bottom: 74px;
background: #3F5D7E url(site/nav-base.jpg) repeat-x 0 100%;
}

#nav ul
{
margin: 0;
padding: 0;
list-style-type: none;
}

#nav li
{
display: inline;
}

Link to example 6

Open Publish - From tables to full CSS

Next

20 - Styling the #nav a element

#nav a
{
display: block;
width: 130px;
padding: 3px 10px 4px 10px;
border-top: 1px solid #fff;
font-weight: bold;
color: #fff;
text-decoration: none;
font-size: 110%;
}

#nav li li a
{
padding-left: 25px;
width: 115px;
font-weight: normal;
background: url(site/bullet.gif) no-repeat 15px 50%;
}

#nav a:hover
{
background: #C7D17A;
color: #263E59;
}

Link to example 7

Next

Open Publish - From tables to full CSS

Next

21 - Styling the content

#content
{
float: left;
width: 340px;
margin: 0 29px;
color: #036;
}

#content h2
{
margin-top: 0;
}

Link to example 8

Open Publish - From tables to full CSS

Next

22 - Styling the blockquote

blockquote
{
float: left;
width: 150px;
margin: 0;
padding: 0;
padding-bottom: 74px;
background: #3F5D7E url(site/nav-base.jpg) repeat-x 0 100%;
text-align: center;
}

blockquote p
{
margin: 0;
padding: 10px;
font: italic 130%/140% times, serif;
color: #fff;
}

Link to example 9

Open Publish - From tables to full CSS

Next

23 - Styling the footer

#footer
{
clear: both;
background: #C7D17A;
padding: 5px 10px;
text-align: right;
color: #263E59;
}

Link to example 10

Open Publish - From tables to full CSS

Next

24 - Pseudo-classes

Pseudo-classes in action

Open Publish - From tables to full CSS

Next

25 - Styling the a element

a:link
{
color: #000;
}

a:visited
{
color: #000;
}

a:focus
{
color: #fff;
background: red;
}

a:hover, a:active
{
color: #000;
background: #C7D17A;
}

Link to example 11

Open Publish - From tables to full CSS

Next

26 - Media types

Open Publish - From tables to full CSS

Next

26 - Moving the CSS into a separate file

Open Publish - From tables to full CSS

Next

27 - Link code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Company Name</title>
<link rel="stylesheet" href="stylesheets/simple.css" type="text/css" media="screen">
<link rel="stylesheet" href="stylesheets/import.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="stylesheets/print.css" type="text/css" media="print">

Open Publish - From tables to full CSS

Next

28 - Setting up the print CSS

There are a range of choices from honouring the screen design to serving a simplified black and white version. The choice depends on the site, the audience, the content and the client.

Assuming we were to use the simplified option:

Open Publish - From tables to full CSS

Next

29 - Styling to body for print

body
{
margin: 0;
padding: 0;
font: 100% times, serif;
background: #fff;
color: #000;
}

Open Publish - From tables to full CSS

Next

30 - Styling to header for print

h1
{
border-bottom: 1px solid #000;
}

Open Publish - From tables to full CSS

Next

31 - Styling to nav for print

#nav
{
display: none;
}

Open Publish - From tables to full CSS

Next

32 - Styling to blockquote for print

blockquote
{
background: #ddd;
margin: 1em 0;
padding: 1em;
}

blockquote p
{
margin: 0;
}

Open Publish - From tables to full CSS

Next

33 - Styling to footer for print

#footer
{
border-top: 1px solid #000;
padding-top: 1em;
margin-top: 2em;
text-align: right;
}

Open Publish - From tables to full CSS

Next

34 - Styling to a element for print

a
{
color: #000;
text-decoration: none;
}

Link to example 12

Open Publish - From tables to full CSS

Main

35 - Wrapping up

Initial layout

Finished layout

Thank you