HTML 2011
HTML 2011
A bit of history…
• The world wide web began as a way to share
documents on the internet (which was
starting to gain a foothold with other
functionality like email & newsgroups).
• It was introduced in 1990 by English
physicist Tim Berners-Lee and Belgian
computer scientist Robert Cailliau while both
were working at CERN.
HyperText Markup Language
• Initially, the documents that were shared on the
WWW were text documents that were “marked-up”
with extra tags to define the structural or visual
aspects of the document.
• Another effect of this language was to add extra
functionality into the document, such as links to
other online pages, creating a network of
interconnected documents (this is the “hypertext”
portion of the html name).
Fast-forward to now…
• As computer technology and the WWW have
evolved, html has continued to allow the
content of web pages to evolve.
• Aside from just links, we now enjoy
multimedia content and applications that are
seamlessly integrated into dynamic web
pages, allowing the WWW to do much more
than facilitate the sharing of documents.
Overview of HTML
• Files have the .html or .htm extension.
• Files can be composed in ordinary text
editors.
• Subsets of the text can be enclosed in “tags”
to give that portion of text some structure or
functionality:
<tag>blahblahblah</tag>
• Tags have the general form:
<tagname attribute1=“value1” attribute2=“value2”>
An Example
The following code: Would look like:
<html>
<title>Example</title>
<body>
Hello World
</body>
</html>
Some Formatting Tags
• <p>, </p> - start and end of a paragraph
• <b>, </b> - start and end of bold text
• <i>, </i> - start and end of italicized text
• <u>, </u> - start and end of underlined text
• <br> - insert a line break to override the
default behavior of just wrapping the text
around to the next line.
Some More Formatting Tags
• <h1> , </h1> - set enclosed text to be a
“Level 1 heading” (also <h2>, <h3>, etc.)
• <font> , </font> - set font for enclosed text
with style options set in tag. i.e. -
<font face = “Arial” color = “blue” size = “10”>blahblahblah</font>
• Note: web browsers ignore all but the first
space between pieces of text, and any line
breaks in your .html file. It is the tags you
include which determine how the page will
look, not the way it looks in your text editor.
Another Example
<html>
<title>Example #2</title>
<body>
<p><h1>Level 1 heading</h1></p>
<p><h2>Headings are already
<b>bold</b> but not
<i>italicized</i></h2>
Here is a line of text.
It seems like this should be
on a new line, but it's not.
<br>
<font face = "arial" size = "3"
color = "blue"> You need to
use a line break to make a
new line or else the text
wraps around when it reaches
the right side of the
window. </font> The font tag
changes the look of your
text.
</body>
</html>
Lists
Unordered List
<ul>
<li>First Item
<li>Second Item
<li>Third Item
</ul>
<p>
Ordered List
<ol>
<li>First Item
<li>Second Item
<li>Third Item
</ol>
Images
• Obviously, additional content besides text is crucial
to an effective webpage.
• Images can be added to your page with the <img>
tag : <img src=“file location”>
• The file’s location can be a URL for its location on
the internet or its location on a local disk.
• Ex: <img src=“http://cramer.ccr.buffalo.edu/logos/ccr_logo.jpg”>
would look like:
Links
• Links enable the web to be a network of
interconnected documents, rather than a
static collection of pages.
• Links use the <a> , </a> tag (short for
anchor) and can link to other pages, other
locations in the current page, or even an
email address.
Linking to Another Web Page
• You can enclose some text with the <a> tags
to make it a link, and you must provide a
destination for that link to point to using the
href attribute:
<a href=“some url”>link text</a>
• Example:
<a href=“http://www.ccr.buffalo.edu”>CCR</a>
Would translate to: CCR
Linking to Another Web Page
target="_blank“ Opens new page in a new browser
window
“_self“ Loads the new page in current
window
“_parent“ Loads new page into a frame that
is superior to where the link lies
“_top"Loads new page into the current
browser window, cancelling all frames
<a href="http://www.sicom"target="_blank">
SI.COM</a>
Linking Elsewhere In The Page
• The anchor tag can be used to name a
location in your document:
<a name=“topofpage”></a>
• A link later on in the document can refer to
this anchor by name and take the reader
there: <a href=“#topofpage”>Back to top</a>
Linking To An Email Address
• Instead of pointing to the URL of another
webpage, or a location in the current
document, the href attribute can point to an
email address:
<a href=“mailto:emailaddress” >
• Ex:
<a href=“mailto:[email protected]”>Send me an email</a>
Would look like:
Send me an email
Using Images as Links
• Like other tags, the <a> and <img> tags can
be nested so an image can function as the link
activator instead of text:
<a href=“http://www.ccr.buffalo.edu”>
<img src=“http://cramer.ccr.buffalo.edu/logos/ccr_logo.jpg”>
</a>
Would yield:
Tables
• More than just adding a table for data, html
tables can be used to structure the text,
images, links, etc. that make up your
webpage.
• You can use tables to define the layout for
your page, and then fill the appropriate table
cells with the content you want.
• A table is defined with <table> & </table>.
Within the table, rows are defined with <tr>
& </tr> . Within each row, cells are defined
with the <td> & </td> tags.
A Table Example
<b>Table</b><br>
<table>
<tr>
<td>Row 1, Col 1</td>
<td>Row 1, Col 2</td>
</tr>
<tr>
<td>Row 2, Col 1</td>
<td>Row 2, Col 2</td>
</tr>
<tr>
<td>Row 3, Col 1</td>
<td>Row 3, Col 2</td>
</tr>
</table>
Some Refinements
• Well, that table seemed to help with the
layout, but it could definitely look better.
• There are lots of attributes that can be
modified to adjust the look and layout of
your table. Some of these are illustrated in
this next example.
Attributes
• Attributes amplify tags. That is, when a browser
interprets a tag, it will also search for attributes and
then display the element (tags+attributes).
• Examples: background color, table width
<tr>
<td> Column 1 </td>
<td> Column 2 </td>
</tr>
<tr>
<td> Row 1 Cell 1 </td>
<td> Row 1 Cell 2 </td>
</tr>
<tr>
<td> Row 2 Cell 1 </td>
<td> Row 2 Cell 2 </td>
</tr>
</table>
Comments
• Tables can be given backgrounds using the bgcolor
attribute.
• Also, backgrounds are not limited to the <table> tag;
you can give separate backgrounds to <td> and <tr>.
• The <tr> tag must always be placed before the <td>
tag.
• As you see, good form is important in organizing the
table code. It may seem a bit complicated, but if you
keep everything organized it will be much easier to
manage later.
• <!-- A comment -->
Putting It All Together
• Each cell of a table can contain any other html
object: links, images, lists, etc.
• The code for this table is on the next slide.
<table width=800>
<tr>
<td width=640 height=84>
<img src="http://cramer.ccr.buffalo.edu/logos/ccr_logo.jpg">
</td>
<td rowspan=2>
<ul>
<li>Bioinformatics
<li>Consulting Services
<li>Grid Computing
<li>Visualization
</ul>
</td>
</tr>
<tr>
<td align=center valign=top>
<a href="http://www.ccr.buffalo.edu">CCR Website</a>
</td>
</tr>
</table>
Music Links
<embed src="Good Riddance (Time of Your
Life).wma" autostart=“true" loop="false"
volume="60" />
Exercise
Find the music files in your directory, and the
associated album covers.
Make a table with 3 columns, 2 rows, giving the
artist, cover image, and a link to the music file, for
each song.