Intermediate Web Design
Intermediate Web Design
Intermediate Web Design
Table of Contents:
1. Getting Started
2. Meta Tags
3. Favorites Icon
4. Brief Introduction to CSS
5. Syntax
6. Adding to an HTML Page
7. Div and Span
8. Links Color Change
9. Building a Site without Tables
Quick Tip:
Did you know that you can view the html used to make any page you visit (called the “source
code”)? Simply right click, and select View Source or go to the View option on the menu bar
and select Source
• Quick and fast right? Notice the blue highlighting for html code… this will
come in handy when hunting down bugs. Also, Dreamweaver automatically
ends your tags, which is very helpful and probably cuts down 99% of HTML
errors.1
2. Meta Tags
Meta tags are inserted in the <head> region of your web page and used to
convey information that is not viewable in a browser. Meta tags in general “work
1If you ever used Notepad for HTML pages… it can get very frustrating when you miss that </tag>…
Webworks: Lists, Tables, and Frames Page 2 of 14
behind the scenes” and a human visitor will not care too much about them. They
are usually used to help increase search engine rankings by including relevant
information about the page. As we all know, pages on the internet are usually not
what they claim to be in a search engine...
A little friendly note: If you want to be ranked #1 in a search engine like Google, meta tags
alone will not help you because they use a different algorithm in site ranking. The moral
of the story here? Content > flashy junky stuff. If you have good content, more people
will link to you, thus driving up the site ranking.
<head>
</title> RabbitWorld </title>
<meta name = “description” content = “All you want to know about
rabbits.”>
<meta name = “keywords” content = “rabbits, bunnies, bunny, world, no
sleep”>
<meta name = “robots” content = “noindex”>
</head>
Another useful meta tag is REFRESH. Use this little snippet of code for
redirecting to another site.
Notice the number 5 inside content. This is the number of seconds before the
browser will attempt to redirect so you can have a little message in the main
page “Please wait FIVE seconds before jumping to another page!”
Dreamweaver automatically includes a meta tag in the new generated HTML file:
Content-type tells the browser what sort of character set (iso-8859-1) to load so
the page will look correct. This is optional, but this meta tag can be left alone.
Now you want to include your own customized icon for your own site!
Start by drawing a 16x16 image and convert it into the icon format. Save the icon
as favicon.ico. Upload this icon onto your web space and put the following code
inside the <head> tag to link to the icon:
Refresh your webpage, and the favorites icon will be replaced with your own
customized icon!
If your computer doesn’t have a program to convert picture files to icons, here are
some links to icon converting programs:
• http://www.pcworld.com/downloads/file_description/0,fid,22323,00.asp
http://www.mostshareware.com/soft/Image-Icon-Converter-download-
7867.html
An example would be taking a tag <h1> and give it new attributes like
highlighting text with red.
Whenever you want text to be highlighted red, all you have to do is use the <h1>
tag instead of using <font color= “red”></font>. Since CSS allows the designer
to separate style from content, this saves a lot of time when editing pages and
makes HTML code easier to read.
Style is identified with its <style> </style> tags, and these tags will show up as
purple in Dreamweaver.
Want an example of CSS in action. You’ll find tons at the CSS Zen Garden
(http://www.csszengarden.com/).
5. Syntax
CSS sytnax is easy to remember: selector, property, and value.
The selector is the HTML tag you want to modify, property is an attribute you
want to modify with a value.
Example:
The <p> tag is your selector, “font-family” is the property that will be
modified by the value “verdana, arial, helvetica.”
You can also make style definitions easier to read by spacing them out and writing
each property on a different line:
span
{
color:red
font-style: italic
}
When modifying fonts using CSS, there are units and values that should be kept in
mind:
• em – height of a character
• px – pixels
• pt – point
• % - percentages!
body { font-size:10px; }
External
This is the most common implementation of styles. The CSS code is in a separate
file with a “.css” extension (NOTE: You must have the .css extension). A snippet is put in
the <head> section of the HTML file specifying where the style sheet is. For
example, if you had a style sheet called main.css in your styles folder under your
web directory, your HTML will be:
<head>
<link rel="stylesheet" type="text/css" href="./styles/main.css" />
</head>
The CSS file would then just contain your CSS code AND NOTHING ELSE. For
example if all your style sheet did was set the background color of your pages to
yellow, the CSS file would look like this:
Using external style sheets makes it easy to apply the style sheet to multiple
pages. Even better, any changes you make to the source style sheet cascades and
updates the styling of all your pages.
Internal/Embedded
Say you apply an external style sheet to your page, but then want just one page
to have a blue background. Then you can include the page specific CSS code
within the <head> section of your page. While other styles of your external style
sheet come through, the background color style of the external sheet will be
overridden by the internal stylesheet in the page. Now the CSS code needs to be
wrapped with special <STYLE> tags in the HTML:
<head>
<style type="text/css">
<!-- body { background-color: blue;}-->
</style>
</head>
The use of comments within the style tag is to hide the code from someone
viewing the page with a really old browser. All the code will be displayed on the
screen and that looks really bad, so take the extra 2 seconds to comment out the
style area!
Inline
Inline uses of CSS is generally not recommended and is slowly being faded out.
Inline CSS is where you stick the style directly inside a HTML tag. For example:
<p style=”color:green”>
The text in this paragraph would then be green.
</p>
The only time you would use Inline CSS is if you need one instance of CSS, say
highlighting a sentence or something that would be difficult to do with other HTML
methods.
You can use more than one of these implementations. When they conflict, the
order of precedence:
1. Inline styles
2. Internal styles
3. External styles
Custom Selectors
Besides selecting HTML elements to apply styles to, you can also create your own
custom element names to apply to any element. Custom styles take two forms,
CLASS and ID.
CLASS
ID
#someothername {color: red; }
p.redpen {color:red}
p.greenpen {color:green}
Comments!
Comment as often as possible! You might have to look at your code several
months or years down the line, and realize you don’t understand what is going on
because you failed to document it properly!
Comments will not be displayed in the page; they only appear in the source. They
also appear as gray in Dreamweaver.
<span> is used to tell the browser to apply formatting. The big difference
between <div> and <span> is <div>’s ability to create paragraph breaks (line
break before and after.) <span> elements only affect a small chunk of text in a
line.
<div class="blueback">
</div>
The width of a <div> can be set, and the importance of this will be discussed
later.
In this example, “a” is the “a” in <a href =”....”></a> and we can apply the
following style changes:
When correctly done, the link should be displayed in light blue and once the user
hovers over the link, it should be underlined and in red.
Position
This property allows the coder to determine where a block of text will go in the
page.
• Static – places the block wherever it is
• Absolute – places the block in the page defined by the coder
.somewhere {position: absolute; top: 50px; right: 100px; }
(This places the block of text 50 pixels from the top, and 100 pixels
from the right)
• Relative – places the block where it would have been if there was nothing
around.
Border
This is the standard property that allows us to draw lines around blocks of text.
There are many border styles, ranging from solid to ... hidden.
For the ubiquitous thin border you see all the time, use this code:
Up to this point, a simple two-column page can be created using the following
code:
Adding a third column is very easy, just create a new ID with the position of the
third area. Use the <div> tags in the <body> region of the HTML code
(remember that <div> tags are like blocks of text) and you’re done!
Float
This property “floats” a block of text or image in a direction (left or right or
nowhere.)
#flt_right { float: right;} /* self-explanatory */
Multiple blocks with the same float direction will appear alongside each other. To
create the effect of blocks stacked on top of each other, but still floating towards
a direction, use the CLEAR property.
Without clear:
With clear:
Useful Tags
Background
Property Values Description
Background-color Red, blue, FFFFFF,
transparent, etc Sets the background color
Border
Property Values Description
Border-color Red, blue, FFFFFF,
etc Sets the color of the border
style
border(bottom can be replaced
by left, right, or top)
Border-bottom- See border-width Sets the style of the bottom
width
width (bottom can be replaced
by left, right, or top)
Classification
Property Values Description
Cursor Auto, crosshair,
default, pointer, Sets the type of cursor to
move, text, wait, display
help
Display None, inline, block,
list-item, run-in,
compact, marker,
table, inline-table,
table-row-group,
table-header-group,
table-footer-group, Sets how an item is displayed
table-row, table-
column-group, table-
row, table-column-
group, table-column,
table-cell, table-
caption
Float Left, right, none Sets where an item will appear
within another
Position Static, relative,
absolute, fixed Sets where to put the item
Dimension
Property Values Description
Height Auto, pixels, 30% Sets the height of an item
Line-height Normal, #, pixels,
30% Sets the distance between lines
Font
Property Values Description
Font-family Family name
Sets the font family (Allows a
(Arial)or a generic
name (serif) list by priority)
List
Property Values Description
List-style-type None, disc, circle,
square, decimal,
lower-roman, upper- Sets the type of the list marker
roman, lower-alpha,
upper-alpha
List-style- Inside, outsider Sets where the marker is
position
placed
List-style-image None, url Sets an image for the list
marker
Margin
Property Values Description
Margin-bottom Auto, length, % Sets the bottom margin of the
element
Margin-left Auto, length, % Sets the left margin of the
element
Margin-right Auto, length, % Sets the right margin of the
element
Margin-top Auto, length, % Sets the top margin of the
element
Outline
Property Values Description
Outline-color Color, invert Sets the color of the outline
around an item
Outline-style None, dotted,
dashed, solid, Sets the style of the outline
double, groove, around an item
ridge, inset, outset
Outline-width Thin, medium, thick, Sets the width of the outline
length around an item
Padding
Property Values Description
Padding-bottom Length, % Sets the padding on the bottom
of an item
Padding-left Length, % Sets the padding on the left of
an item
Padding-right Length, % Sets the padding on the right of
an item
Padding-top Length, % Sets the padding on the top of
an item
Position
Property Values Description
Bottom Auto, %, length Sets how far from the bottom of
Table
Property Values Description
Border-collapse Collapse, separate Sets the border of a table to
collapse or separate
Border-spacing Length Sets the distance between
borders of two cells
Empty-cells Top, bottom, left, Sets whether empty cells
right should have a border
Table-layout Auto, fixed Sets how the table is to be laid
out
Text
Property Values Description
Color Blue, green, FFFFFF,
etc Sets the color of the text
characters
Text-align Left, right, center,
justify Aligns the text