Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

Introduction to HTML

Lars Vogel

Version 1.6

14.11.2010

Revision History
Revision 0.112.04.2008Lars Vogel
Created
Revision 0.2 - 1.612.06.2008 - 14.11.2010Lars Vogel
bug fixed and enhancements

HTML5

This article is a overview of HTML5.


Table of Contents

1. HTML5
1.1. What is HTML?
1.2. Your first HTML page
1.3. CSS
1.4. A structured example
1.5. HTML validators
2. HTML Standard Elements
2.1. Blocks and structural elements
2.2. HTML Links
2.3. Lists
2.4. Tables
2.5. Image
2.6. Special signs
3. Forms
4. Canvas
5. Drag and Drop
6. Geolocation
7. Local storage
8. XHTML
9. Thank you
10. Questions and Discussion
11. Links and Literature

1. HTML5

1.1. What is HTML?

HTML (Hypertext Markup Language) is a standard to describe the content of webpages. HTML pages are text files which typically end with the ".html" extension. HTML is a so called "markup language". The current version of HTML is HTML5. This version is still work in process but is already widely adapted by the browser vendors. HTML5 supports XML syntax. This article uses the HTML5 XML syntax.

1.2. Your first HTML page

HTML files needs to be plain text. Use a simple text editor, e.g. Notepad under Windows and save the following text as "page1.html". Do not use a editor such as Winword as this editor saves additional information in the file. Create the following text.

				
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8"> 
  <title>An HTML5 Document</title>
 </head>
 <body>
  <h1>Your first HTML5 page</h1>
  <p>This is a <a href="http://www.vogella.de">link</a> to another webpage</p>
  <!-- this is a comment -->
 </body>
</html>

			

Open this page in a browser, e.g. by double-clicking on your page. The result should look like the following.

In HTML you describe the structure of webpages in pure text — by defining text as headings, paragraphs, lists, etc. A tag is a text surrounded by angle brackets. Tags usually have a beginning and and end and contain other text between the start and end tag. The normal content of the webpage is placed between the <body> </body> tags, the <head> </head> tag contains general information about the webpage.

1.3. CSS

HTML by ifself does not define a lot of display options. You use CSS to define how HTML element should be displayed.

1.4. A structured example

HTML5 introduced several new ways of classifying content of the webpage, e.g. <nav> </nav> for the navigation part of the page, <article> </article> to represent an independent article, <aside> </aside> to represent a sidebar with related information. <footer> </footer> for a footer in the HTML page and <address> </address> for the contact information of the author.

The following displays an example which uses these new elements. Most browser will not change the display based on them but you can use CSS to select these elements and style them accordingly.

				
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8"> 
  <title>An HTML5 Document</title>
 </head>
 <body>
  <h1>Your first HTML5 page</h1>
  <header>
  <nav> 
  	<a href="http://www.vogella.de">Home</a> 
  	<a href="http://www.vogella.de/eclipse.html">Eclipse Tutorials</a> 
  </nav>
  </header>
   <article>
    <section>
		 <p>This is a <a href="http://www.vogella.de">link</a> to another webpage</p>
    </section>
  </article>
  <aside> Stuff which is on the side.</aside> 
  <details> Details can be <mark> hidden </mark>.  </details>
 <footer> Footer.</footer>
 
 </body>
</html>

			

1.5. HTML validators

You can use http://validator.w3.org/ to check the validity of your HTML code.

s