Software: XHTML
Basic Structure
The basic structure of a web page is extremely simple. The really exciting thing about writing HTML, is that you can test it out immediately to see how it works. Let's start by producing some very simple web pages just to get some practice. Open up the text file "index.html" located in the "practice_sties" then xhtml folder that you copied to the desktop.
Follow along with this basic XHTML structure tutorial to create the basic outline for your first web page.
Activity: Open the index page in the xhtml folder and follow along with the tutorial adding the XHTML to your web page. When you finish continue moving through the tutorials on this page until you reach the "Additional Information" Section.
HTML is broken down into elements, attributes, and values.
Understanding HTML Building Blocks Tutorial
Block-level elements are like the building blocks of your initial mark-up of the page. They start things on a new line and give a little space above and below the element. Use these to create an outline of your information.
| Type | Element(s) |
|---|---|
| Headings | h1,h2,h3,h4,h5,h6 |
| Paragraphs | p |
| Block (long) quotes | blockquote |
| Preformatted text | pre |
| Various list elements | ol,ul,li,dl,dt,dd |
| Horizontal rule (lines) | hr |
Paragraph | <p>
Paragraph tags are the most basic elements. Simply open a <p> tag at the beginning of a paragraph and put a closing </p> tag at the end. Paragraphs can contain text, images and inline elements within the p tags but make sure not to include any other block elements.
Activity: Add the paragraph tag to the paragraph of text on your index page.
Headings | <h1,2,3,4,5,6>
If you have ever made an outline you know that headings are used to communicate the hierarchy of information. Even though heading tags will change the way your text looks in HTML, you need to ignore the presentation because we will be changing that with our style sheets. Think of the heading numbers as being levels of importance. For example, if you are planning to use the heading tags:
Activity: Use a heading 1 tag for the "School Adz" title at the top. Use a heading 2 tags for the "Links" title near the bottom of the page.
Horizontal Rule | <hr />
The horizontal rule is a simple tag often used to separate section of your page. It basically puts a line across your page with a little space above and below. Horizontal rules can be formatted use style sheets. It is a self closing tag so make sure to include the "space forward slash" at the end.
Activity: Add a horizontal rule to at the bottom of all the web pages.
Lists | ol,ul,li,dl,dt,dd
There are basically three types of list in HTML.
Activity: Use a series of unordered list to help organize the information on the businesses and form pages and the navigation links on all pages. Use a definition list to format the information on the contacts page. We will use style sheets to format these list later.
Sometimes you want to break up a line of text but don't want that extra space above and below that a paragraph tag give you. That is where line breaks come in. The inline line break element <br /> allows you to force text or images onto the next line without that space. It is an empty element so it will be self closing.
Inline Text Elements | <em> and <strong>
We are only going to focus on the two semantic inline text elements that indicate that text should be emphasized. The cool thing about these two is that some screen readers will change the tone of voice to convey the emphasis! This are tags need to enclose the text they are formatting with an open and closing tag.
Activity: Emphasize the word FREE on the home page.
Since HTML uses characters like the < (less than) sign in the coding of a web page browsers might mistake it if you try to using it in the content of your page. So there is both a "numberic" and "named" way to get these special characters onto your web page. Use the "Special Characters" chart in the Files/Coding Examples folder for reference.
Activity: Replace the quote marks on the home page with special characters.
The best thing about the World Wide Web is how everything is connected through hypertext or hyperlinks. In this lesson you will learn how to link to other peoples web sites, web pages within your site, links within a web page, to an email address and how to control what window those links open in. To use the anchor element or hypertext link, simply suround your text or image with an opening <a> tag and then closed with a closing </a> tag and use the href attribute to provide the URL. For example, to link to Google you would use <a href="http://www.google.com"> Google </a>. Hypertext can be typically identified by an underline and a color other than the rest of the text. A hyper linked image is sometimes surrounded by a blue border or changes when your pointer moves over it. You can tell an image or text is hyper linked when the mouse pointer changes to a hand when it moves over the link.
The href attribute tells your browser which page to display. In addition to linking to web pages, you can also link to images, audio and video files.
Absolute URLs: When you want to link to someone elses web site you will need to use an absolute URL. It will always start with the protocol (http://). I suggest you copy this from a browser and then paste them into your code to ensure they are accurate.
Example: href="http://www.google.com"
Relative URLs: When you want to link to pages or media within your web site you will use relative URLs. That way they will work regardless of whether the files are on you computer at home, on the web server (FTP), or your network drive at school because their relationship to each other is "relative". The tricky part about relative linking is going up or down in your directory (folder) structure. When you want to go into a folder you will add the folder name and a forward slash before the file name. When you want to get out of a folder and link to a file you will use ../ before the file name.
Example #1: href="forms/form.html" <<This example would go into a folder to open a file called "form.html"
Example #2: href="../contacts.html" <<This example would go out of the current folder the file is in and open a file called "contacts.html"
Linking Tips:
Activity: Use an absolute link for the "Mount Si Home Page" link (http://www.mountsihighschool.com). Use a relative link to the contacts.html. Test the pages.
Absolute and Relative Links Tutorial
You can create a link that will automatically launch a mail program and preaddress the message to your email address. Just include mailto: before the email address within the href value. However this only works when the viewer has their browser configured correctly. Therefore you should always include the email address as part of the hypertext.
Example: <a href="mailto:webadmin@svsd410.org"> dockeryj@svsd410.org </a>
Tips & Tricks
Here is a tutorial that will show you how to code in the subject line or send the email to additional people. More
Activity: Create a hyperlink to your email on the "contacts.html" page.
Images make a web page more interesting but slows the download time. Images can be displayed on a web page as an inline content or as a tiled background. We will be using style sheets for placing images into the background of our web pages so in this lesson we will concentrate on putting them on the page as an inline element.
Inline images can be used three basic ways.
Make sure that you only use GIF, JPEG, or PNG files in your web pages. All imaging applications will allow you to save your images as one of these formats. We will cover these in much more detail later in the class. For now try to follow these basic rules:
Just make sure that when you write your code you include the correct file extension. Example: <img src="images/photo.jpg" />
The <img />tag is a self closing inline element. Which means a couple things. First you will need to include it within another block level element (parapgraph, heading, div). Second, that by default it does not add space above or below the image and it can be place in the flow of text. You will need to use a couple attributes that help the browser handle the img tag.
Tips
File Transfer Protocol
Try using both the following applications to transfer our files to your folder on the web server. Text to make sure the web pages are displaying properly. Then delete the files from the web server.
All the web pages that you create for our company must include this basic structure. You will also be required to include meta tags. They give search engines information about your site. Check out the W3Schools for more information about meta tag elements. I will expect an author and generator tag on every page you make. Add keywords and description to each of the web site home pages you make. |
The <!doctype> declaration is the very first thing in your document, before the <html> tag. This tag tells the browser which HTML or XHTML specifications the document uses.
Use this DTD when you need to use XHTML's presentational features because your readers don't have browsers that support Cascading Style Sheets (CSS):
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Coding Terms and Company Policy
Since we have many employees working in our company, we expect all our employees to follow the same simple set of conventions.
Differences Between XHTML and HTML - Some of the tutorials in this class will be based on outdated HTML coding. Use these guidelines in updating your coding. *Rated "Excellent Resource" by our guest BCC instructor.
Some of the tutorials that we use, will not follow these conventions. However, since this is company policy, you will be expected to follow them. Your employee evaluations will be assessed using these conventions!
Please review this tutorial explaining all of the XHTML standards you will be expected to use in this course.
HTML Time Saver
Generic elements allow you to create a block level <div> or inline element <span> that has no inherent presentation but uses style sheets to do all the formatting. We are going to use the <div> tag to create block level containers for positioning each of the sections of our page. Then when we apply our cascading style sheets we can format these sections anyway we want.
Since both the div and span tags are empty you need to give them an element identifier (id or class). The id identifier is used for identifying unique or one of a kind elements. For example we are going to use the following div elements, but only once on each page. These elements must be opened and closed around the text that you want to format. The class identifier is used to identify similar elements so it can be used multiple times on the same web page.
Activity: Add the following div tags to the web pages.
Activity: Add a current page span tag to the title of the current page in the navigation list.
You can link to a specific point on a web page. As you have seen from navigating around on the pages in the course, I have created both links down to certain sections and multiple links back to the top of the page. This is a two step process.
Step 1 - Name the Destination: The first thing you will do is to use the id attribute to identify the target element in the document. For example, on our web page if you wanted to create a link back to the top you would add an id attribute to the heading 1 tag of the page title.
Example: <h1 id="top">School Adz Contacts </h1>
Step 2 - Link to the Destination: The second thing you will do is to create a link to the top using the a element. In the href attribute you will use the number symbol (#) and then the destination name.
Example: <a href="#top"> Click Here to Go to the Top of the Page </a>
Activity: Create give the page titles on your businesses.html and forms.html pages a unique id and then link to them from the bottom of these two web pages.
Linking to a Specific Point on a Page Tutorial
You can add an additional attribute to the anchor (a) tag that allows you to target a specific window. This is important when you design a site using frames. I have used the target="_blank" attribute in this course to open my tutorials in a new window. Don't use this technique on our School Adz site though.
Where to open the target URL.
Tables are a great way to present tabular information or information that makes more sense in a table format. For example, a calendar is a great example of information that makes more sense in a table. We are going to create a very basic table and then later we are going to format it with style sheets.
We are going to build our tables using just the minumal table structure and then add a few elements to increase the accessiblity of the data. To start lets learn about the basic table elements.
You will be expected to stagger the indention of your code when coding a table.
Activity: Create a web page with the same basic structure that we have been using. Copy the table data from the "table" file in the Unit 03 "Files" folder and paste it into the web page. Above the data build a table with five rows and four columns. Then copy and paste the data from the "Table Body text" section into the table data cells. Then test the web page to see how it looks. Remember it will not look fancy but the information should be organized into rows and columns.
The information in a table often has a row or column that is designed as a header. In our example, we need to add a new row with the column headers from our data. By applying the <th> table header tag you will notice that the text in this row will be formatted slightly differently than the text in the rest of the table. We can always change this with style sheets later.
Activity: We will do this by adding another row at the top of the table but instead of using the <td> table data tag we are going to use the <th> table header tag.
Sometimes you will need to make a row that spans across all the columns or a column that spans across multiple rows. For this we use the colspan and the rowspan attributes.
Activity: Add another row to the bottom of the table but only include one <td> table data cell. Then add the colspan attribute to the table data tag and include the number of columns that it will need to span.
Example: <td colspan="4">
Dy default the data in are sized to fit the data in the cells. If you want to add a little more room around the data or inbetween the cells, you will use the cellpadding and cellspacing attributes in the opening table tag. Think of cellpadding as the room inside a room (jail cell). Think of cellspacing as how far apart each room is placed.
Example: <table cellpadding="10">
Captions and Summaries
There are two additional methods for providing people with information about your table, captions and summaries. Add either right below the opening table tag with an open and closing tag surrounding your text.
Activity: Add the caption text given to you for your table.
Caption and Advanced Elements Tutorial
You can describe rows and groups of rows as belonging to a header, body or footer. This will help to organize your table and make it easier to read.
Activity: Add an opening and closing <thead> table head tag and <tbody> tag to define the header row and the body rows.
For more information about making your Tables Accessible go to: http://www.usability.com.au/resources/tables.cfm
Forms allow you to gather information from your web site visitors. If you have ever signed a guest book, ordered something or filled out any information online, you have used a form. Some of School Adz customers may want you to create a simple form for them.
There are two parts to a form:
Forms gather information and then can do a variety of things with this information.
The <form> Element
The opening form tag is important because it directs the information gathered from the form. There are two main attributes in this tag.
Don't forget to close the your form tag at the bottom with a </form> tag! Forms can contain block level elements such as headings and list but should never include another form element.
Web forms use a variety of controls to allow viewers to enter information. Most of these controls use the <input> element.
Form controls include:
The Name Attribute
All of these controls require a name attribute. This attribute identifies what information is being gathered. These names are coded into the program on the server so they have to be very specific.
Example: Hours: <input type="text" name="hours"> This input might send the following information back to the server: hours=9:00%to%5:00%pm
Form Control Name Values
Name=name
Business=business
Phone=phone
Email=email
Hours=hours
Address=address
City=city
State=state
Zip Code=zip
Do you currently have a web site?=current_website
password=password
Describe your business=describe_business
Do you have any information or images in electronic form?=electronic_information (yes and no)
Text=text
Images=images
Text
Submit and Reset Buttons
These are the only controls that don't require a name value because they do not return any information to the server.
You can change the text on either of these buttons by using the value attribute.
Example: <input type="reset" value="Clear Form" /> will give you a button that with the text Clear Form on it.
Submit and Reset Control Tutorial
Radio and Checkbox Buttons
Radio and Checkbox Control Tutorial
Menus
Menus are a more compact way to present the viewer with a bunch of choices. The <select> element opens and closes around a bunch of <options> elements. The option elements open and close around your options. Make sure to close the option element after each option and close the selection after the last option.
States: Washington, Oregon, Idaho, California, Arizona, Alaska
File Selection
You can use the file selection control to allow your users to upload files to your server. You must use the POST method in your form tag and you must specify the encoding type of the form as multi-part/form-data. We will not be using this control on our form.
Example: <input type="file" enctype="multipart/form-data" name="photo" />
Hidden Controls
Hidden <input type="hidden" /> controls allow you to send information to the program on the server that doesn't come from the user. For example you might want to specify a web page that the user is directed to after they submit the form. These controls are set by the program on the server so we will have to wait until our Business Advisor has created our server side program.
<input type="hidden" name="subject" value="Joe's Test Form Data">
Activity: We will simply surround our text and form control with an open and close <label> tag. In our form we can use a fieldset and legend for the contact information and one for the business information.
I have set up a Gmail email account to check the results of your form. Just go to Google and click on "Gmail".
Username: schooladzformchecker@gmail.com
Password: U2L7form
We will be using php to handle our form data. You will need to download these files to your "forms" folder and edit one of them. Then upload all of them to your forms folder on the ftp server.
Activity: The "mshs_form.php" file is the only file you need to open and edit. There are two things to do here.