Everything you need to know about web standards and design in 3 minutes!

I am working on updating some slides for an upcoming HTML course and stumbled across this brilliant video that explains everything you need to know in about three minutes, including why you need to use a standards based approach to design.

Here’s the lyrics

Your site design is the first thing people see
it should be reflective of you and the industry
easy to look at with a nice navigation
when you can’t find what you want it causes frustration
a clear Call to action to increase the temptation
use appealing graphics they create motivation
if you have animation
use with moderation
cause search engines can’t index the information
display the logos of all your associations
highlight your contact info that’s an obligation
create a clean design you can use some decoration
but to try to prevent any client hesitation
every page that they click should provide and explanation
should be easy to understand like having a conversation
when you design the style go ahead and use your imagination
but make sure you use correct color combinations
do some investigation, look at other organizations
but don’t duplicate or you might face a litigation
design done, congratulations but it’s time to start construction
follow these instructions when you move into production
your photoshop functions then slice that design
do your layout with divs make sure that it’s aligned
please don’t use tables even though they work fine
when it come to indexing they give searches a hard time
make it easy for the spiders to crawl what you provide
remove font type, font color and font size
no background colors, keep your coding real neat,
tag your look and feel on a separate style sheet
better results with xml and css
now you making progress, a lil closer to success
describe your doctype so the browser can relate
make sure you do it great or it won’t validate
check in all browsers, I do it directly
gotta make sure that it renders correctly
some use IE, some others use Flock
some use AOL, I use Firefox
title everything including links and images
don’t use italics, use emphasis
don’t use bold, please use strong
if you use bold that’s old and wrong
when you use CSS, you page will load quicker
client satisfied like they eating on a snicker
they stuck on your page like you made it with a sticker
and then they convert now that’s the real kicker
make you a lil richer, your site a lil slicker
design and code right man I hope you get the picture
what I’m telling you is true man it should be a scripture
if it’s built right you’ll be the pick of the litter
everyone will want to follow you like twitter
competition will get bitter and you’ll shine like glitter
if you trying to grow your company will get bigger
design and code right man can you get with it

Using div tags, CSS, and Image Sprites to create a rounded box for your content

One popular design feature of many sites these days continues to be a section of framed content in a box. Some examples include the boxes that you can see on sites like CNN, or twitter just to name a few.

A framed content box that is shown on twitter

A framed content box that is shown on twitter

CNN's take on the framed box

CNN's take on the framed box

This is a perfect example of how to use nested div tags to create such an effect that has the ability to scale in width so there is no need to change the top image every time you decide to change the width of the page. If you are new to html and css you probably read the title of the article and wondered to yourself what sprite has to do with any of this, right? Sprites are a series of images that have all been combined in one image, make sense? See when you design a user interface for a website some elements are bound to be repeated over and over again, and you may want to cut doen on the round trips to the server that are made when a resource like an image is requested by the browser, the answer is creating a sprite, or a collage of all the images that will be used by the interface in ‘background-image’ css declarations. Just like the screen the coordinates 0,0 are given to the top left hand pixel of an image, therefore you can pick just the slice of a large image that you want to show in the background of a div tag. A good example would be the left hand corner below, see you start at 0 pixels from the left and 0 pixels from the top (‘background: url(‘../../testsomethings/images/bg_sprite.gif’) 0px 0px;’ ) which happens to be right where the left hand curve is at, then you go 9 pixels wide and done. For the right we use the same image but we start from the far right and go 9 pixels back toward the left ( background: url(‘../../testsomethings/images/bg_sprite.gif’) -352px 0px; ). Now for the center piece we have to go down 100 pixels from the top or else we will see the curve appear in the center box, so we use ( background: url(‘../../testsomethings/images/bg_sprite.gif’) 0px -100px ; )

You can see that the classes involved in box include:

  • roundedbox – this is the container that holds the entire box
  • header – this is the top of the box and it contains the left corner, right corner, and center sections of the round box.
  • leftCorner – this holds the left hand corner so that the background image will give the box the effect of being rounded.
  • rightCorner – this holds the right hand rounded image in the background
  • center - this is the repeating center image and also contains the heading which has been placed in a h2 tag with the font properties adjusted for readability.
  • content – this div holds the actual story content and contains the gradient grey background slice which fades into white.

You can see the code below here ( http://www.learnsomethings.com/testsomethings/rounded_corners.html ).

You can see the sprite here, but you could probably do a much better job matching the boxes yourself ( http://www.learnsomethings.com/testsomethings/images/bg_sprite.gif ).

The CSS

<style>
.roundedbox .header {
                position: relative;
                height: 33px;
                width: 100%;
                z-index: 200;
}

.roundedbox .header h2 {
                font-size: 16px;
                color:#FFF;
                font-weight:200;
                margin-left: 3px;
                margin-top: 3px;  
                display: inline;
                float: left;  
                font-family:Verdana,sans;
}

.roundedbox .leftCorner {
                background: url('../../testsomethings/images/bg_sprite.gif') 0px 0px;
                height: 33px;
                width: 9px;
                position: absolute;
                left: 0;
                top: 0;
}

.roundedbox .center {
                background: url('../../testsomethings/images/bg_sprite.gif') 0px -100px ;
                height: 33px;
                position: absolute;
                left: 9px;
                right: 9px;
}

.roundedbox .rightCorner {
                background: url('../../testsomethings/images/bg_sprite.gif') -352px 0px;
                height: 33px;
                width: 9px;
                position: absolute;
                right: 0;
                top: 0;
}

.roundedbox {
                position:relative;
                display:block;
                float:right;
                margin:8 8 8 8;
                padding: 0;
                width:100%;
}
.content {
                position:relative;
                display:block;
                background: #fff url('../../testsomethings/images/widgetBG.gif') bottom repeat-x;
                padding:6px 10px 6px 10px;
                font-family:Verdana,sans;
                font-size:12px;
                line-height:1.4em;
                list-style-type: disc;
}
</style>

The html that is required to make one of the boxes to the left consists of several div tags to comprise the various parts of the container.

The HTML code

<div class="roundedbox" >
                <div class="header">
                  <div class="leftCorner"><!-- I'm just here to make
                        the left corner rounded--></div>
                  <div class="center">
                        <h2 title="" role="complementary">Headline News</h2>
                  </div>
                  <div class="rightCorner"><!-- I'm just here to make
                        the right corner rounded--></div>
                </div>
       <div class="content" >
             <p>Some great content would normally go here, and
               maybe even a thumbnail image!<b>Read More ... </b>
             </p><br />
       </div>
</div>

Changing your html table (made with markup) into a dynamic sortable html table with YUI (Yahoo User Interface)

Ajax Table

Sortable Table

To illustrate the power of Ajax in class one of the simplest and most striking examples is the progressive enhancement html datagrid. The yahoo user interface or YUI is a set of javascript widgets that you can incorporate into your page to instantly add functrionality such as drag and drop, dropdown menus, sortable and editable tables, layout, styled message boxes and much more. The focus of this article is a simple html table example. Let’s start with the following code which should produce a table that is your standard 1995 style html table.

The Code:

<html>
<head>
<title>Progressive YUI grid – step by step</title>
</head>
<body>

<table>
              <thead>
                            <tr>
                            <th>Some Value</th>
                            </tr>
              </thead>
              <tbody>
                            <tr>
                            <td>23</td>
                            </tr>
                             <tr>
                            <td>34</td>
                            </tr>
                             <tr>
                            <td>76</td>
                            </tr>
                             <tr>
                            <td>98</td>
                            </tr>
                            </tr>
              </tbody>
</table>
</body>
</html>

The Outcome:

Some Value
23
34
76
98

That’s all great, but you may want to offer sorting, movable columns, and a generally more appealing user interface for your tables. The first step to our table’s transformation is to add the links to the YUI scripts that will transform your table. Place the following into your tags.

<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/datatable/assets/skins/sam/datatable.css">
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/element/element-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/datatable/datatable-min.js"></script>

The files above will transform your page by applying the CSS classes to the table and applying the Javascript that will give the table the ability to react to your mouse clicks. Now you might be wondering how get the links that you need and more importantly what order should they be put in. To answer that question you can go to http://developer.yahoo.com/yui/articles/hosting/ and click on the buttons corresponding to the widget that you want to use in your page, finally copying the code into the clipboard and pasting into your page.

Next you have to add the yui-skin-sam class to the tag in your page.

<body class="yui-skin-sam">

Now enclose the table in a div tag like the code below and give your table an id.

<div id="markup">
<table id="sometable">
<thead>
<tr>
<th>Some Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>23</td>
</tr>
<tr>
<td>34</td>
</tr>
<tr>
<td>76</td>
</tr>
<tr>
<td>98</td>
</tr>
</tbody>
</table>
</div>

Now under the closing div tag place the following script which will be explained after the code snippet.

<script type="text/javascript">
YAHOO.util.Event.addListener(window, "load", function() {
    YAHOO.example.EnhanceFromMarkup = function() {
        var myColumnDefs = [
            {key:"somevalue",label:"Something",sortable:true}
        ];

        var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("sometable"));
        myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
        myDataSource.responseSchema = {
            fields: [{key:"somevalue"}]
        };

        var myDataTable = new YAHOO.widget.DataTable("markup", myColumnDefs, myDataSource,
                {caption:"This is some caption",
                sortedBy:{key:"due",dir:"asc"}}
        );

        return {
            oDS: myDataSource,
            oDT: myDataTable
        };
    }();
});
</script>

Notice that ==> var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get(“sometable”)); points to the id of the table. That is your datasource.

Now look at following and notice that markup is the name of the div that surrounds your table, this is where your new datatable will be drawn.

var myDataTable = new YAHOO.widget.DataTable("markup", myColumnDefs, myDataSource,
                {caption:"This is some caption",
                sortedBy:{key:"due",dir:"asc"}}
        );

Finally, here is the code for the simple example.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>My First YUI Table</title>
		<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/fonts/fonts-min.css">
		<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/datatable/assets/skins/sam/datatable.css">
		<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
		<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/element/element-min.js"></script>
		<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/datasource/datasource-min.js"></script>
		<script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/datatable/datatable-min.js"></script>
	</head>
	<body class="yui-skin-sam" >

		<div id="markup">
			<table id="sometable">
			<thead>
				<tr>
				<th>Some Value</th>
				</tr>
			</thead>
			<tbody>
				<tr>
				<td>23</td>
				</tr>
				<tr>
				<td>34</td>
				</tr>
				<tr>
				<td>76</td>
				</tr>
				<tr>
				<td>98</td>
				</tr>
			</tbody>
			</table>
		</div>
		<script type="text/javascript">
YAHOO.util.Event.addListener(window, "load", function() {
    YAHOO.example.EnhanceFromMarkup = function() {
        var myColumnDefs = [
            {key:"somevalue",label:"Something",sortable:true}
        ];

        var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("sometable"));
        myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
        myDataSource.responseSchema = {
            fields: [{key:"somevalue"}]
        };

        var myDataTable = new YAHOO.widget.DataTable("markup", myColumnDefs, myDataSource,
                {caption:"This is some caption",
                sortedBy:{key:"due",dir:"asc"}}
        );

        return {
            oDS: myDataSource,
            oDT: myDataTable
        };
    }();
});
</script>
	</body>
</html>

What you should know after the first HTML class:

What you should know after the first class:

First of all you can find a complete listing of tags at http://www.w3schools.com/html5/html5_reference.asp

There is a complete listing of CSS values at http://www.w3schools.com/css/css_reference.asp

Html is a series of tags, they start with a < followed by the tag name, a space then the attribute followed by an = sign and the attribute value in “ “ quotes. They are then closed by a >

There are two types of tags, self closing, or those which hold no content between   them such as:

<img src=”somepicture.jpg” />

and those that contain content between the opening and closing tags such as,

<a href=”somepage.html” > This is a link! </a>

There are four tags that you must have in your page


<html>
 <head>
 </head>
 <body>
 </body>
</html>

CSS or cascading style sheets control the display of the page.

An example of a class:

 .name {
 attribute1:property;
 }

An example of a rule (applies to all tags):

 p  {
 attribute1:property;
 }

We have set up an account on a server that hosts your websites that you will be creating throughout the course, when you get home the method by which you will access the files on this site is:

1) Open Aptana
2) Right click on the ‘projects’ folder (see image below)

Right click on the projects folder and select add new project

Right click on the projects folder and select add new project.

3) Select existing hosted project (see image below):

Select existing hosted project

Select existing hosted project

4) Choose default location and press next
5) Give your project a name (see image below):

Give your project a name and press 'next'

Give your project a name and press 'next'

6)Click on the ‘new connection’ button and complete the blanks using the site information that you received from www.freewebhostingarea.com

Now click on the new connection button, fill in the information and watch your site appear!

Now click on the new connection button, fill in the information and watch your site appear!

Session Three – Forms, Tables, and some Aptana Answers

Session three is upon us and we did not get to start tables as planned so first we will go over the tags that make up a table, mainly <table> <th> <tr>, and <td>, and create the periodic table as that will allow you to use almost every element in the table tag.  Finally, we will get into java script basics as well as the document object model or DOM, so in addition to the Box Model you will know the Document Object Model, as with last week a lot of useful information will reside in the ‘Rhino’ book, otherwise known as : JavaScript: The Definitive Guide, Fourth Edition. I have attached a copy of the periodic table below so we can print it out as we will want to define the columns on paper just as we did with the div tags.

In addition I would like to go over some real world Aptana questions, such as how you connect this to your server, upload pages, and use it to build your site.

We will cover pages 162 -185 except the two pages on file uploads, as well as 244 – 249 as we start javascript. We will also cover tables in the other book.

This weeks slides are at : http://docs.google.com/present/edit?id=0AQSJT255xS0WZHhoZnBtZl8xNzEyNG5kbW1kbg&hl=en

We will make this table in class!

We will make this table in class!