36
Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College Wed, Feb 20, 2013 Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 1 / 36

Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Basic HTMLLecture 14

Robb T. Koether

Hampden-Sydney College

Wed, Feb 20, 2013

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 1 / 36

Page 2: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 2 / 36

Page 3: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 3 / 36

Page 4: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

HTML

HTML = Hypertext Markup Language.“Markup” refers to tags embedded within the text that tell how thetext is to be rendered.For example, the <b> tag will render text in boldface.“Hypertext” refers to links to other documents or links within thesame document.The anchor tag <a> contains a hyperreference.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 4 / 36

Page 5: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

HTML

HTML<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML

4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">

An HTML file may begin with the above tag.This gives the browser information about the version of HTML thatis being used, along with other information.

W3C = Worldwide Web ConsortiumDTD = Document Type Definition4.01 = HTML Version 4.01EN = Englishloose = Loose enforcement

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 5 / 36

Page 6: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

HTML Tags

Most tags have a corresponding closing tag.For example, the closing tag for <b> is </b>.A few tags are self-closing.For example, the line break tag <br/> is self-closing.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 6 / 36

Page 7: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 7 / 36

Page 8: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

HTML Structure

HTML Structure<html>

<head>headers

</head><body>

body of document</body>

</html>

An HTML document is enclosed in <html> tags.Within these tags are the <head> and <body> sections.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 8 / 36

Page 9: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

The header

Titles<head>

<title>My First Webpage</title></head>

The header may contain the title of the page.The title will appear in the title bar of the browser window.Later, we will place PHP and Javascript functions in the headersection.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 9 / 36

Page 10: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

The body

Paragraphs<body>

<p>This is the first paragraph

This is still the first paragraph</p><p>This is the second paragraph</p>

</body>

The body contains the content to be displayed.Text that is not within tags is rendered as plain text.Every span of white space is equivalent to a single blank space.The paragraph tag <p> can be used to break the content intoparagraphs.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 10 / 36

Page 11: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Basic Example

Basic Example<html><head><title>My First Web Page</title></head><body><p>Q: Why did the opossum cross the road?</p><p>A: To prove it could be done.</p></body></html>

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 11 / 36

Page 12: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 12 / 36

Page 13: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 13 / 36

Page 14: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Headings

Headings<h1>Hampden-Sydney College</h1><h2>Databases and Dynamic Webpages</h2><h3>Coms 480</h3><h4>Spring 2013</h4><h5>Bagby 020</h5><h6>MWF 12:30</h6>

There are six levels of headings, with tags <h1> through <h6>.Level 1 is the largest; level 6 is the smallest.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 14 / 36

Page 15: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Headings

Centering<h1 align="center">Hampden-Sydney College</h1><h2 align="center">Databases and Dynamic Webpages</h2><h3 align="center">Coms 480</h3><center><h4>Spring 2013</h4><h5>Bagby 020</h5><h6>MWF 12:30</h6></center>

The headings may be centered.Use the <center> tag, orUse the align attribute.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 15 / 36

Page 16: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 16 / 36

Page 17: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Text Face

There are several choices for the text face.<b>Bold text</b><i>Italic text</i><tt>Teletype text</tt>

Combinations are possible.<b><i>Bold Italic text</i></b><i><tt><b>Italic Teletype Bold text</b></tt></i>

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 17 / 36

Page 18: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 18 / 36

Page 19: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Lists

HTML can create ordered lists <ol> or unordered lists <ul>.An unordered list is a bulleted list.An ordered list is a numbered list.Each item in a list is tagged with a list-item tag <li>.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 19 / 36

Page 20: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Lists

Unordered List<ul>

<li>Randolph-Macon College</li><li>Roanoke College</li><li>Hampden-Sydney College</li>

</ul>

An ordered list of colleges.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 20 / 36

Page 21: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Lists

Ordered List<ol>

<li>Hampden-Sydney College</li><li>Roanoke College</li><li>Randolph-Macon College</li>

</ol>

An ordered list of colleges.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 21 / 36

Page 22: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 22 / 36

Page 23: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Hyperreferences

Hyperreference<a href=’hyperreference’>link_text</a>

An anchor tag <a> is used to create a hyperreference.When the user clicks on the link_text, the link is activated.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 23 / 36

Page 24: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Hyperreferences

HyperreferenceRead the details <a href="http://www.foxnews.com/...slide=1">here</a>

The link text will appear underlined and in a different color.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 24 / 36

Page 25: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 25 / 36

Page 26: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Images

Images<img src="filename" />

An image may be included in a document by using the image tag<img>.An alt attribute may be included, in case the image does notload.The height and width of the displayed image may be included,using the height and width attributes.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 26 / 36

Page 27: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Images

ImagesDon’t be rusty in math:<img src="//people.hsc.edu/faculty-staff/robbk/MarkTrail.jpg"alt="Mark Trail comic" height="314" width="336" />

The height and width do not need to match the dimensions of theimage.Change the file name to Mt. Blanc.jpg.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 27 / 36

Page 28: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 28 / 36

Page 29: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Tables

The table tag <table> may be used to format information intabular form.Within the table element we may list any number of table rows,using the <tr> tag.Each entry in a row is indicated by a table data tag <td> withinthe table row elements.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 29 / 36

Page 30: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Tables

Tables<table>

<tr><td>table_entry</td>

...<td>table_entry</td>

</tr>...

</table>

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 30 / 36

Page 31: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Tables

Tables<table>

<tr><th>column_heading</th>

...<th>column_heading</th>

</tr>...

</table>

The first row (or any row) of a table may be designated as tableheadings by using the <th> tag instead of the <td> tags.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 31 / 36

Page 32: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Tables

The <table> tag may take a number of attributes.border = Size of the table border, in pixels.cellpadding = Padding within cells between the table entry andthe cell border, in pixels.cellspacing = Spacing between adjacent cell borders, in pixels.width = Width of the table either in pixels or as a percent of thewindow’s width.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 32 / 36

Page 33: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Tables

Text

Cellspacing

Border Cellpadding

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 33 / 36

Page 34: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Example

As a simple example, see the HTML file for the syllabus on thewebsite for this course.Create a web page showing the data in the employees table ofthe company database.Create a photo album of 12 photos with captions, arranged in 3rows of 4 photos each.

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 34 / 36

Page 35: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Outline

1 HTML

2 HTML File Structure

3 HTML ElementsHeadingsTextListsHyperreferencesImagesTables

4 Assignment

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 35 / 36

Page 36: Lecture 14 Robb T. Koether - Hampden-Sydney Collegepeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures... · 2013-02-20 · Basic HTML Lecture 14 Robb T. Koether Hampden-Sydney College

Assignment

AssignmentVisit the W3Schools website

http://www.w3schools.com/html/Visit the sections labeled “Introduction” through “Lists.”

Robb T. Koether (Hampden-Sydney College) Basic HTML Wed, Feb 20, 2013 36 / 36