make work easy.

john ivanoff

use css+xhtml

Why?

  • reduce mark up
  • increased separation of content and presentation
  • improved accessibility
  • forward compatibility
  • save bandwidth
  • easy maintence

forta table needs cleared!

original

let's look at ben forta's blog. he was nice enough to say I could you his site for this example.

here we go.

keep it simple.

forta blog xhtml

use valid xhtml and structured html.

We use the appropriate tags for the content. <h1> for headings and <p> for text. we will use style sheets to make it pretty.

<div>ide and concur

the css

<div>ed

we divide the xhtml into sections. the header, sidebar, content, footer.

#header { background-color: #ccc; }
#sidebar { background-color: #999; }
#content { background-color: #fff; }
#footer { background-color: #eee; }

putting things in their place

the css

local navigation

we'll float the sidebar navigation to the right side of the page like a column.

#sidebar {
	float: right;
	width: 25%;
	background-color: #999;
	}

it's not a column.

the css

local navigation colum

put a margin on the content div to make the sidebar look like a column.

#content {
	background-color: #fff;
	margin-right: 25%;
	}

movin' on up

content to the top

let's move the content closer to the top. if viewed in a browser that doesn't support styles we won't have to scroll forever to get to the good stuff.

we float the content to the right and give it a width of 72% to make a gutter.

d'oh

the css

float, float on

since we change the structure of the doc we'll need to adjust our css

#content {
	float: left;
	width: 72%;
	background-color: #fff;
	}

no!

i don't like change. why is the local navigation on the right?

the css

please conform

we'll fix that.

#sidebar {
	float: left;
	width: 25%;
	background-color: #999;
	}
#content {
	float: right;
	width: 72%;
	background-color: #fff;
	}

get ride of the grey matter

the css

color

let's add some color.

body {
	margin: 0;
	padding: 0;
	background: #363;
	color: #000;
	font-family: Verdana, Arial, Helvetica, sans-serif
	}
#header {
	/*background-color: #ccc;*/
	}
#sidebar {
	float: left;
	width: 25%;
	/*background-color: #999;*/
	}
#content {
	float: right;
	width: 72%;
	background-color: #fff;
	padding: 10px 0 10px 10px;
	margin: 0 10px 0 0;
	}
#footer {
	clear: both;
	/*background-color: #eee;*/
	text-align: right;
	}

it's worse

the css

linkology

let's style the links in the local navigation.

#sidebar {
	float: left;
	width: 25%;
	font-size: 90%;
	/*background-color: #999;*/
	}
#sidebar p{
	font-weight:bold;
	color: #ffffff;
	text-align: center;
	}
#sidebar form{
	font-weight:bold;
	color: #CCCCCC;
	}
#sidebar a{
	font-weight:bold;
	color: #CCCCCC;
	}
#sidebar a:hover{
	font-weight:bold;
	color: #FFFFFF;
	}
#sidebar td{
	color: #CCCCCC;
	}

stop! header time

the css

oh oh, oh oh.

we'll format the header to look like the old one.

#header {
	/*background-color: #ccc;*/
	}
#header ul {
	display: inline;
	} 
#header ul li {
	margin-left: 0;
	padding: 0 10px;
	border-right: 1px solid #cccccc;
	list-style: none;
	display: inline;
	}  
#header a{
	font-weight:bold;
	color: #cccccc;
	text-decoration: none;
	} 
#header a:hover{
	font-weight:bold;
	color: #ffffff;
	}
#header h1 {
	float: left;
	margin: 0;
	padding: 0;
	text-indent: -9999px;
	width: 150px;
	height: 65px;
	background: transparent url(../images/drk_grn_logo.png) top left no-repeat; /*relative to css file*/
	display: block;
}
#header h1 a {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	text-decoration: none;
	background: transparent url(../images/drk_grn_logo.png) top left no-repeat;
	}
#header p{
	color: #cccccc;
	font-size: 10pt; 
	font-weight: bold; 
	text-align: right;
	background-color: #000000;
	border-bottom: 1px solid #ffffff;
	padding: 10px;
	margin: 0 0 15px 0;
	}

let's adjust

the css

squint

we'll make the content smaller so it's harder to read.

body {
	margin: 0;
	padding: 0;
	background: #363;
	color: #000;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: small;
	}

add a div to disclaimer

.disclaimer p{
	font-size: 80%;
}

what day is it?

the css

calendar

we'll format the calendar

#sidebar table{
margin: 10px;
background-color: #FFFFFF;
}
#sidebar table td {
color: #336633;
}
#sidebar table td a {
	font-weight: bold;
	color: #3366cc;
	}
#sidebar table td a:hover {
	font-weight: bold;
	color: #000000;
	}

nav-b-gone

the css

the wrapper

when window is adjusted we can 'lose' the local navigation. time to wrap it up and make final adjustments. it also looks 'boxy.'

#wrapper	{
	margin: 0;/* auto;*/
	padding: 0;
	border: 0;
	width: 700px;
	text-align: left;
	}

are we done?

the css

final

look ma only one table and it's for the calendar.

tables aren't evil. they are great for displaying tubular data, not as a layout tool.

mr. clean

remember, casade style sheets + xhtml and you will be spotless.