ITEC
745 - Roderick - Fall 2005 |
||||||||
|
||||||||
| Updated: April 4, 2005 | ||||||||
Exercise 1: Separating Structure and Presentation Example 1. Start by opening a New Blank HTML page in Dreamweaver. 2. Copy the following code
into a new blank page (copy over existing HTML code) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <body bgcolor="#FFFFCC" text="#666666" link="#FF0000" vlink="#FF6600"> <p><font size="6" face="Courier New, Courier,
mono">Bob Student's Home Page</font></p> STRIP HTML PRESENTATION 3. This page has been constructed without a style sheet. Our goal is to remove any deprecated tags or any tags which are purely for presentation and replace the desired presentation style with style sheet elements. We will want to remove the following elements:
There are a couple ways to do this which will make it easy even if you do not 'know the code". However, we will be forced to do some of this by hand. 3a. Switch to "Split" view at the top of your Document Window. 3b. Let's start by selecting the first block of text at the top of the page, the header of the document which reads "Bob Student's Home Page". 3c. Notice the Tag Selector at the bottom of the Document Window. This shows you the array of HTML tags that are currently selected. You can see that one of those tags is "<font>". In the Tag Selector, right-click on the <font> tag. In the list menu that appears (see below), select "Remove Tag". This works well for removing the elements. For our purposes, we will use this to clean up <font> tags.
3d. Removing attributes, which are values of HTML tags (things like "width="50%""), are a little different. You will need to use the "Edit Tag" feature (see below). When selecting this, an "Edit Tag" window pops-up which allows you to hand-edit attributes within the tag and just that tag. It's nicer for the HTML uninitiated since you don't have to sift through all of the code, but only the code that you wish to edit. Select the code you wish to remove, click Delete or Backspace and be sure to remove any extra spaces and leave the tag in a proper fomat (ie: <body> NOT <body >).
The web page will look like this when upon removal of these elements and attributes. 4a. Rebuild <body>Tag: We will start by creating an external style sheet for this page which will contain the styles we will be creating for this page. Once the style sheet is created, we'll start by rebuilding the <body> tag. Here is how it looked in the original code and we can see that it is creating the background color, standard text color, and link text color for unvisited and visited links. <body bgcolor="#FFFFCC" text="#666666" link="#FF0000" vlink="#FF6600"> We can handle the background color and standard text color by creating a "Tag" in the style sheet window and creating a Style for the <body> tag. The other two attributes (link and vlink which affect link colors) will be handled in another way (in 4b.).
Using the Style Definition window, we will start by addressing the Font Color in the <body> tag (represented by the attribute "text='#666666'"). To do this, select the "Type" Category. Using the "Color" item, select the color "#666666"
Next, select the "Background" Category and using the "Background Color" item, select the "#FFFFCC" color from the pick list. 4b. Rebuild <body>Tag Continued:
Click the "New CSS Style" button and in the "New CSS Style" window, select the "Advanced" type and from the tag window, select the "a:link" tag. This will allow us to start by creating the tag color for the link tags. Click OK and the "CSS Style Definition" window will appear. Under the "Type" category, change the color to match the "#FF0000" as defined in the "link="#FF0000" attribute. Now, repeat the action, this time selecting "a:visited" from the "Advanced" drop down menu. This time, in the "CSS Style Definition" window, select the "#FF6600" color as defined in the vlink="#FF6600" attribute. 5. Rebuild <table> Tag: We should keep in mind that while this particular page only has one table in its construction, many sites make use of multiple tables and there are also many more pages within the site that would refer to this style sheet. So in the case of this style sheet, we'd want a global rule that meant by default, all tables in the site would be 770 pixels. When creating a style sheet rule for <table>, you should keep in mind the HTML Redefinition rules will affect all instances of the tag. Therefore, when creating an HTML Redefintion for a tag, the initial tag should be setup with attributes that most of the <table> tags within the page will use. You will also need to create id selectors (Advanced) which will allow you to create alternative <table> tags which can be applied to specific <table> tags but we will not need to do this in this exercise. Let's start by selecting the "New CSS Style" button and selecting the "Tag" option and select "<table>" from the drop down menu. In the "CSS Style Definition" window, we'll select the "Box" Category. Under "Width" we'll enter "770" pixels to match the original attribute of the <table> tag. With the "CSS Style Definition" window still open, we'll select the "Border" category. Under "Style" select "Solid" (note: make sure the "Same For All" item is checked) and select "1 pixel" under "Width". Under "Color", select the appropriate color you'd like your border to be. We'll deal with the "cellspacing" at the cell <td> level in the next step. 6a. Rebuild <td> Attributes: <td width="145" valign="top" bgcolor="#000000"> <td width="625" valign="top"> The two attributes they have in common are that both refer to "valign="top" and, from our <table> tag, they both have a "cellpadding="4"" reference. We'll start by selecting the "New CSS Style" button and selecting the "Tag" option and select "<td>" from the drop down menu. In the "CSS Style Definition" window, to recreate the "valign="top"", we'll select the "Block" category and under "Vertical Alignment" we'll select "Top" from the drop down menu. To recreate the "cellpadding="4"", we'll select the "Box" category and under "Padding", select "4 pixels". Next, we'll need to deal with our exceptions to the <td> tag. In the first case, both have different widths. Secondly, the first <td> has an attribute of bgcolor. 6b. Rebuild <td> Nav Area:We'll start with the first <td> tag. To create
an exception or different version of the <td> Redefined tag, we'll
create a CSS Selector. Select the "New CSS Style" button
and select the "Advanced" option.
In the "Name" entry, delete whatever tag may
be showing up there, if any, and type the following: "td.nav".
This signifies a new variation of the <td> tag and we'll call it "nav"
because it's to create attributes for the navigation portion of our page.
Now, in order to apply this new Advanced style to the correct <td> cell, we'll have to select the appropriate <td> cell in our page. The best way to do this is to click your mouse within the table cell we wish to affect, in this case, the one with the navigation. To make sure you've indeed selected the <td> tag, go to the "Tag Selector" at the bottom of the design window (the horizontal list of tags going along the page) and select the closest <td> tag. Check the design window to make sure the proper cell is selected. Next, select the "Style" drop-down menu from the Property Inspector. You should see "nav" tag showing up (and nothing else because Redefined HTML tags will not show up there -- they need not be applied because they automatically affect the tag itself). Select the "nav" and that Selector style will be applied to the navigation cell. 6c. Rebuild <td> for Content Area:Next, we'll do the same for our content area which merely needs the "width" attribute recreated. Go through the steps above to create an Advanced Selector but this time, name the selector "td.content". In the "CSS Style Definition" window which will then appear, to recreate the width tag, select the "Box" category, enter "625 pixels" under the "Width" entry. Then, as described above, select the appropriate <td> cell for the content area, and then, under the Property Inspector "Style" menu, you will see a "content" tag (in addition to the "nav" tag). Select the "content" tag and the width should take on the cell. 7. Rebuild <font> Tag: Our last step will be to apply the proper styles to recreate the <font> element. 7a. Rebuild Font <body> Reference: To recreate this, we'll assign this font style to the <body> HTML Redefined tag which we've already created. Go to the "CSS Styles" window, locate the "body" style, right-click on it and select the "Edit" from the menu that appears. This will open the "CSS Style Definition" window. Under the "Text" category, select "Courier New, Courier, mono" from the "Font" drop down menu. Click OK. You should now notice all of the text in the Design window change to the appropiate font face. 7b. Rebuild Title Text: The above reference is to the large title text at the top of the page. Structurally, that would probably be best served with an <h1> tag. However, we don't need to create a style for the <h1> tag since it will inherit the "face" properties for Courier, etc. from the <body> tag (done earlier) and it's inherent sizing will replace the "size" attribute.
7c. Rebuild the Nav Text Sizing: The above reference is part of the navigation. It contains a particular font size and is also surrounded by the <strong> or bold tag. The <strong> tag is acceptable but we will have to reproduce the size style. So we'll Make a "Class" to deal with the sizing of the navigation text which has a size of "4". Select the "New CSS Style" button and select the "Class" option. In the entry window, delete whatever appears there and type "navtext" (we want to name it differently from our earlier Selector item). You will merely have to provide a new size and you'll find that "18 pixels" works well. To apply this Class style, go ahead and select the entire navigation text, go to the Property Inspector, selec the Style menu and select the "navtext" item on the list. You should notice the style become applied to the text. You can now also add the "<strong>" tag by selecting "B" button from the Property menu at the bottom of the page.
7d. Rebuild the Content Area Text Sizing: The above reference has yet another size attribute for the content area. So, we'll do the same for the other cell (content) text which is sized at "2". Follow the same steps, this time, naming the Class "contenttext". You'll find that "14 pixels" should work fine.
7e. Rebuild the Footer Text Sizing: The above reference has yet another size attribute, this time for the footer line. So, we'll recreate the proper sizing for the footer which was sized at "1". Follow the same steps as above, this time, namgin the Custom Style "footertext". You'll find that "9 pixels" works well.
Your page should now look like this. Compare to the original. |
||||||||
| © 2005 Andrew
Roderick. Some Rights Reserved. ( Creative
Commons License). XHTML | CSS | 508 Email Instructor | Department of Instructional Technology - San Francisco State University |
||||||||