45
HTML - basic tags - How to learn more

HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Embed Size (px)

Citation preview

Page 1: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML- basic tags

- How to learn more

Page 2: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

What is HTML?

• HyperText Markup Language• HTML5:– Recommended by the W3C

Page 3: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML

• “HTML is the lingua franca for publishing hypertext on the World Wide Web ”

• Structure and format of documents defined by <tags>.

• Enables connections between documents through hyperlinks

http://www.w3.org/MarkUp/

Page 4: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML

Earlier version of HTML (HTML 4.1) offered :– text– multimedia– hyperlink features– scripting languages– style sheets

Page 5: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML 4

Strengths:• Standard (ISO 8879)• Text-based => interoperabilityIssues:• Consequences of popularity and flexibility

(sloppy syntax)• Explosion of device types (Mobile phones,

PDAs, appliances, etc)

Page 6: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML – conceptually

Attractive proposition:• Basic set of HTML tags• Extension framework

Page 7: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML5 – In practice

• Today’s standard for web development • Backwards compatible with earlier versions• Good browser compatibility• Extensions developed for non-standard devices• Makes programming for accessibility easier• Allows separation of content and style (e.g.for

mobile delivery)• Easy to learn – Countless resources available– http://www.w3schools.com– http://validator.w3.org/

Page 8: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Historical summary

SGML

XML

HTML

XHTML

Page 9: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Basic example

Hello World!

Page 10: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Hello World!

<html>

<body>

Hello World

</body>

</html>

Page 11: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Another basic example

Page 12: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Hello world 2<html>

<body><h1>Some formatted text</h1><p>This is a paragraph. Text can be formatted easily: <i>italic</i>, <b>Bold</b>,

<u>underlined</u>, <i><u>italic and underlined</i></u> (note that underlining isn't a good stylistic choice on the web, guess why?).

</p>

<h1>A bullet list</h1><ul> <li>Apples</li> <li>Pears</li> <li>Bananas</li> <li>Oranges</li></ul>

<hr/><p><i>Author: Gr&eacute;gory Lepl&acirc;tre</i>

</body>

</html>

Page 13: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Hello world 2 – (1)

<html>

<body>

(…)

<h1>Some formatted text</h1>

(…)

</body>

</html>

Page 14: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Hello world 2 – (2)<html><body>(…)<p>This is a paragraph. Text can be formatted

easily: <i>italic</i>, <b>Bold</b>, <u>underlined</u>, <i><u>italic and underlined</u></i> (note that underlining isn't a good stylistic choice on the web, guess why?).

</p>(…)</body></html>

Page 15: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Hello world 2 – (3)<html>

(…)

<ul>

<li>Apples</li>

<li>Pears</li>

<li>Bananas</li>

<li>Oranges</li>

</ul>

(…)

</body>

</html>

Page 16: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

<html>

<body>

(…)

<hr/>

<p>

<i>Author: Gr&eacute;gory Lepl&acirc;tre</i>

</p>

(…)

</body>

</html>

Page 17: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

What we have learnt

• Links:– <a> (not yet)

• Structural tags:– <html>, <body>, <p>, <h1>, <ul>, <li>

• Formatting tags:– <i>, <b>, <u>

• Graphical elements:– <hr>

• Special characters:– &eacute; &acirc;

Page 18: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML components

1. A DOCTYPE: <!DOCTYPE html>

2. The <html> tag (must be the first tag of the document, after 1)

3. <head> and <body> tags. 4. The head must contain a character set

definition and a <title>.

Page 19: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

5. <head> tag

• <title> The title appears at the top of the browser. Can be used by search engines.

• <meta> Literally: information about (the page). A typical page will contain several of these tags. Works with name/content pairs:<meta name=“description” content=“This is a test page”/>

• <style> specifies the style sheet to be used (more on this in the CSS lecture)

Page 20: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Title

<title>My first web page</title>

Page 21: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Character set definition

• <meta http-equiv="Content-Type“ content="text/html; charset=ISO-8859-1">

Page 22: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

5. <body> tag

The content of the page must be included within the <body> tag.

Page 23: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Proper HTML Hello World!

Page 24: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML5 Hello World!<!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-

8"/> <meta name="Author" content=“Harry Potter"/> <meta name="keywords" content=“Napier, HTML"/> <meta name="GENERATOR" content=“HapEdit"/> <title>Hello World! page</title></head><body><p>Hello World!</p></body></html>

Page 25: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

HTML tags

Page 26: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Headings

• <h1>, <h2>, … <h6> (h1 largest font, h6, smallest font)

• Example:<h1>Some Basic Examples</h1>

<h2>Example 1: formatting</h2>

http://www.w3schools.com/tags/tag_hn.asp

Page 27: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Spacing

• &nbsp; – non-breaking space: forces the browser to display a white space.

• <p> starts a new paragraph (which must be concluded with a </p>).

• <br/> - line break: starts a new line.

Page 28: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Text formatting

• Bold: <b> or <strong>• Italics: <i> or <em>• Underline: <u> • Preformatted text: <pre>

Page 29: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Lists

There are three types of lists:• Ordered lists – numbered• Unordered lists – bullet• Definition lists

Page 30: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Ordered lists

<ol>

<li>Apples</li>

<li>Bananas</li>

<li>Oranges</li>

<li>Pears</li>

</ol>

http://www.w3schools.com/tags/tag_ol.asp

Page 31: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Unordered lists

<ul>

<li>Apples</li>

<li>Bananas</li>

<li>Oranges</li>

<li>Pears</li>

</ul>

http://www.w3schools.com/tags/tag_ul.asp

Page 32: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Nested lists1. Starters

Sea food chowderSoupe du jourGoats cheese salad

2. Main coursesHaggisSea bassRisotto

3. Sweets– Chocolate mousse– Carrot cake– Apple tart

Page 33: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Tables

2-dimensional representation of data:• <table> tag to create a table, contains …• <tr> tag for each line, which contains …• <td> tag for each columnIn addition:• <th> table headingsFormatting:• Tag attributes

Page 34: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Table example<table border=“3"> <tr> <td>100</td> <td>200</td> <td>300</td> </tr> <tr> <td>400</td> <td>500</td> <td>600</td> </tr></table>

Page 35: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Tables – Important attributes

• border: border width (0 used frequently)• cellspacing: space between cells• cellpadding: space between the cell walls and

content• width: width of the table (% or pixels)

http://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asp

Page 36: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Links

One tag <a>, four types of links:1. Link to a location on the same page2. Link to a document relative to the current

document3. Absolute link to a document4. Email link

General format:<a href = “place to go” > Text to display</a>

The above HTML code will look like: Text to display

Page 37: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

1. Link within documentHTML code Outcome of HTML

in your browser

…….

<a href = “#intro”>1. Introduction</a>

<a href = “#discuss”>2. Discussion</a>

……

<a name = “intro”></a>

<h2>Introduction</h2>

…….

<a name = “discuss”></a><h2>Discussion</h2>…….

1. Introduction

2. Discussion

Introduction

……

Discussion

Page 38: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

1. Link within document

Two steps:1. defines a hypertext link that specifies where you

want to go within a document<a href = “#Part1”>Go to part 1</a>

2. defines the place where you will jump to with a document when you click on the above link

<a name=“Part1”> Part 1 is here </a>

The # sign indicates a location within a document and must be included.

Page 39: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

2. Relative link

Link to a document on the same server:<a href = “path/filename”>link text</a>

Example:<a href = “../index.html”>teaching main page</a>

Page 40: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

3. Absolute link

Link to a document on the same server:<a href = “http://server/path/filename”> link text</a>

Example:<a href =

“http://www.dcs.napier.ac.uk/~mjr/teaching/index.html”>

teaching main page</a>

Page 41: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Images

Images are added using the <img> tag:

<img src=“picture location”/>

Pictures can be used as links:

<a href=“…”><img src=“…”/></a>

http://www.w3schools.com/tags/tag_img.asp

Page 42: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Audio and Video?

• HTML doesn’t support these.• Links to audio or video files are possible.• Ways to embed media in web pages involves

plugins… For multimedia students next year …

Page 43: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Final Exercise

My Web PageMy name is: Xxxxxx XxxxxxxMy characteristics are:

Height 180 cm

Weight 65 Kg

Age 22

Page 44: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Summary

• eXtensible Learning Process– Simple basic principle (tags)– Expand your tag knowledge (w3schools)

• Practice– Next practical– At home

Page 45: HTML - basic tags - How to learn more. What is HTML? HyperText Markup Language HTML5: – Recommended by the W3C

Next week

• Laboratory exercise– HTML

• Lecture– Styling (CSS+ design issues)