CSS Layout
CSS Layout
___________________________________
1) CSS Only. This is the way web sites are being laid out now.
Downside: Browser issues
2) Table-based Layouts (old way to lay out web pages).
Cumbersome design process, slower download times, awkward code
3) Tables and CSS (transitional). As people transitioned to CSS, they sometimes
used tables as the layout foundation and CSS for styles within that layout.
________________________________________________________
Left: Table Layout | Right: CSS positioning of <div> (like pods you can command)
<td>
<div>
(each one of
the areas in
this layout
would be a
table cell)
About divs
What is a <div> tag?
1) <div> is the division tag, creating a division in the page.
Think of it as a pod you can command with its own styles
2) Or, think of a div as a wrapper that you place around content
(e.g., main container, header, side bar, content area, etc.)
3) A <div> inside another <div> is nested. The wrapper is the parent.
Whats so Cool About divs?
Whats cool is that you can position divs like pods on an HTML page in order to lay
out your content (e.g., header, sidebar, etc.). Inside each div, you can have different
styles. For example, inside the header div, you might want to have a navigation bar
with links that are blue text with no underlines. However, in the main content area,
you may want your links to be underlined black text. Etc.
Two Ways to Create a div
1) Highlight some content and then go to Insert>Layout Objects>Div Tag
(notice that the wrapper wraps around the content you selected)
2) Open the CSS Styles panel (Window>CSS Styles).
Click the All button in the panel.
Click the + button at the bottom of the panel to create a new style
Select style type (e.g., class style) and name your style (e.g., .header)
Set your properties for the div (e.g., background color, font, etc.)
Click your cursor on the page and insert the div (Insert>Layout Objects>Div Tag)
Review of Styles
Class, tag, I.D., and Compound styles are actually selectors (we select what to
attach a style to).
Tag selectors: styles get attached to tags such as the <body>, <p>, or <h1> tag
Class selectors: Can be applied multiple times on a page (.redboldtext), by hand to
individual elements.
I.D. selector: can be used only once on a page, used for foundational elements (e.g.,
#header, #sidebar)
Compound selectors: combine two or more styles to apply to a specific div (for
example, if you want links in your side bar to be different than links in your header,
you would create a compound style called something like #sidebar a:link. Another
would be #sidebar a:visited, #sidebar a:hover, #sidebar a:active.
Tutorial
This tutorial teaches float layout (columns are created by floating left and right).
This is a commonly recommended method for CSS layoutits sort of like rigging
your code to do something it wasnt exactly originally intended for, but it works so it
has become standard practice. You will need your preferences to be set properly (see
CSS intro).
For this tutorial, you will need the graphics found at
www.julietdavis.com/COM263/tutorials/CSSlayoutgraphics.html. Or you can use your
own (you will need a background graphic that repeats, a header graphic 760 x 150, a
bullet graphic).
Note: This tutorial creates the divs first and then inserts graphics and other
elements. Another option is to create one div at a time and insert all content into
each one before the next one is created.
(speed test)
Other Options
3-column Layout
The above layout we created is called a float layout because it floats the main divs
left and right. Books and tutorials have many different ways of teaching float layouts,
but here are some techniques below:
1) For 2-column layout (above), we floated left and floated right
2) For 3-column layout (or more), it can work to start with the left column on no
float and then to set the middle and right-hand column on float left (it makes no
sense, since they are positioned to the right of the first column, but it works).
Footers
1) To add a footer, space down and set no float, but set Clear to Rt. What this does
is it stops floating.
AP divs (with Absolute Positioning) Optional info
AP divs have absolute positioning, meaning they dont move, float, etc.they stay
put. The drawbacks: 1) you can only use them for web sites that start in the upper
left of the page and dont float to the middle when browser opens, and 2) many
browsers dont support them. So, theyre pretty much not a great idea these days.
To create a style for one, select advanced and call it #absolute.
TYPE: absolute (yes), relative (to HTML)
Insert AP div using button on insert menu. Apply this style using property inspector.
Dreamweaver Layout Templates
Now that youve torn your hair out, check out the prefab layouts DW already has
when you select FILE>NEW. But notice that they are usually inadequate and
cheesythey wont accommodate the exact layout you create.