This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Basic Markup


Learning Objectives

  • Describe the general structure of a document. I.e. what are some common elements found in a magazine article, newspaper page, or other common printed materials.
  • Identify key structural, or semantic, elements of several common documents.
  • Label a printed page or article with related HTML elements.
  • Memorize the HTML5 Doctype.
  • Memorize the UTF-8 charset meta tag.
  • Create a page outline using HTML tags.
  • Distinguish content markup from presentation.

Task Materials

HTML tags are used to mark structural elements of a page. Structural elements include paragraphs, headers, articles, images, and other aspects of hypertext documents.

HTML tags are surrounded by less than ( < ) and greater than ( > ) characters. There will typically be an opening and closing tag that surrounds the corresponding page content. For example, to denote an HTML document you surround the entire page with opening and closing HTML tags:

<html>
... Page content ...
</html>

The only difference between many opening and closing tags is that closing tags have a forward slash ( / ) preceeding the tag text. As an aside, some tags are self closing. Self closing tags look like this:

<br />

Lets take a look at several basic elements of the HTML. We will start off by creating a simple resume or other document of your choice. The elements we will start with include:

  • <!DOCTYPE html>
  • <head>
  • <meta>
  • <body>
  • <h1>, <h2>, etc.
  • <p>

With this limited set of elements we can begin to construct our own HTML resume.

To begin, create a new, empty text file on your local computer or on HTML Pad.

Once you have a blank document, add a DOCTYPE to the beginning of the document. Doctype is short for 'Document Type Declaration' and associates a particular document with a formally defined mark up definition. Our doctype is html. When a browser, such as Mozilla Firefox, parses a document, the doctype declaration describes the possible tags that the browser may encounter. The HTML5 doctype is below:

<!DOCTYPE html>

After the document type has been declared, we can go ahead and open our <html> tag, which will hold sub-elements of the document:

<html>

Be sure not to close the <html> tag yet, we will place the </html> tag at the end of the document.

Now we will place the document header with a <head> tag. The <head> tag is a container for elements such as the page title, CSS for layout, and JavaScript for dynamic elements. This course does not cover those topics but there are study groups forming here at the School of Webcraft.

<head>

We can insert the page <title> inside of the <head> like so:

Our document will contain encoded characters, in our native language, that web browsers will need to display. It is important for us to tell the browser what character encoding to use. The unicode (UTF-8) standard contains over one million characters from languages around the earth. We set our character encoding as UTF-8 using the <meta> tag.

<meta charset="UTF-8" />

Next we close the <head> tag:

</head>

In an HTML document, the <body> is usually located below the <head>. The body is a container for most of your content. Lets open the body container.

In the body, we will typically have page sections and paragraphs of content. The sections are usually seperated by headers. Lets create a couple of header sections:

<h1>Header 1</h1>
<h2>Header 2 (sub-section)</h2>

The headers are hierarchical and higher number header levels are generally sub-sections of the lower numbered headers. In this example, the <h2> is a sub section of the <h1> element.

The <hgroup>  tag is used for when <h> tags are used consecutively after each other.

The final step on this short trip through the basic HTML tags is the often used paragraph tag <p>. Paragraph tags are used to designate paragraphs within a document. For example:

<p>The quick brown fox jumped over the lazy dog.</p>

At the end of your document, be sure to close the <body> and the <html> with:

</body>
</html>

As you can see, the HTML elements are designed to be easily understood by humans, as well as parsed by computers.

Task Assignment

Please post a working HTML document online. You can do so by posting on HTML pad, pastebin, or any other online code pasting/hosting website. If you have your own web hosting feel free to post your HTML files there, or any other reasonable place you know of. Submit a link to your task by replying to this task.

Task Discussion


  • Moraino   Jan. 10, 2012, 4:27 a.m.
  • Ken Doman   Jan. 9, 2012, 10:14 p.m.
  • Dusty   Jan. 8, 2012, 7:19 a.m.

    Added to pastebin.....http://pastebin.com/dw3XeCsD

     

    <!DOCTYPE html>
    <html>
    <head>
    <title>Hello HTML</title>
    </head>
    <body>
    <hgroup>
    <h1>Header 1</h1>
    <h2>Header 2 (sub-section)</h2>
    </hgroup>
    <p>The quick brown fox jumped over the lazy dog.</p>
    </body>
    </html>

     

    not sure how to link to the live page...sorry. new user to pastebin.

  • Anonym   Jan. 8, 2012, 8:27 p.m.
    In Reply To:   Dusty   Jan. 8, 2012, 7:19 a.m.

    Hey Dusty,

    Could you give us a link to your live page?  Thanks smiley

    demian

  • Anonym   Jan. 9, 2012, 6:32 a.m.
    In Reply To:   Dusty   Jan. 8, 2012, 7:19 a.m.

    Hi Dusty,

    To make your page live, after you have written your code in the right hand section of the htmlpad, click on the link htmlpad.org/intro/ on the left hand side.  This will open your web page.  Then you can copy the address and post it here.  I copied your code and saved it as 'intro'. 

    Your page is: http://htmlpad.org/intro/

    If I'm not clear, let me know.

    demian

  • Dusty   Jan. 10, 2012, 4:18 p.m.
    In Reply To:   Anonym   Jan. 8, 2012, 8:27 p.m.

    https://dl-web.dropbox.com/get/P2PU%20HTML5%20files/index.html?w=42c767a0

    Added a place on dropbox for all to view my files....Thanks in advance for all the help and comments.

  • Anonym   Jan. 11, 2012, 1:37 a.m.
    In Reply To:   Dusty   Jan. 10, 2012, 4:18 p.m.

    BROKEN LINK.  Please try again.

  • Dusty   Jan. 11, 2012, 6:29 a.m.
    In Reply To:   Anonym   Jan. 11, 2012, 1:37 a.m.

    http://htmlpad.org/HTML5intro/

    Try this out....

  • Anonym   Jan. 11, 2012, 10 a.m.
    In Reply To:   Dusty   Jan. 11, 2012, 6:29 a.m.

    Your link is working.  You can use the 'Link' button above (the blue round-ish button) like this:

    http://htmlpad.org/htmlintro/

  • Cyrusso   Jan. 7, 2012, 12:15 p.m.

    I've placed my work under http://htmlpad.org/cyrusso-task1/

  • Anonym   Jan. 7, 2012, 2:05 p.m.
    In Reply To:   Cyrusso   Jan. 7, 2012, 12:15 p.m.

     Hi Janusz,

    You should use <hgroup>  whenever you use more than one <h*> tags ( h1, h2, ...) one after another as you have done in your example.  <hgoup> masks the h2 element from the HTML outline algorithm.

    Demian

  • Cyrusso   Jan. 8, 2012, 5:54 a.m.
    In Reply To:   Anonym   Jan. 7, 2012, 2:05 p.m.

    Hi Demian,

    thanks for correction, i've updated my work http://htmlpad.org/cyrusso-task1/

    Greets

    Janusz

  • Anonym   Jan. 8, 2012, 1:13 p.m.
    In Reply To:   Cyrusso   Jan. 8, 2012, 5:54 a.m.

    Hey Janusz!  Thanks for the update.  Great job!  Feel free to style your page with CSS. demian

  • Amosg   Jan. 4, 2012, 12:48 p.m.

    I placed my code on html pad: htmlpad.org/basicMarkup/

  • Anonym   Jan. 8, 2012, 12:03 a.m.
    In Reply To:   Amosg   Jan. 4, 2012, 12:48 p.m.

    You need the <hgroup> as I mentioned in my comment on your other works.

    Demian

  • Rodotheos   Jan. 4, 2012, 7:18 a.m.

    Here is my second task on basic markup...

    https://dl-web.dropbox.com/get/HTML5_P2PU/basic_markup.html?w=79643b31

  • Anonym   Jan. 8, 2012, 12:08 a.m.
    In Reply To:   Rodotheos   Jan. 4, 2012, 7:18 a.m.

    BROKEN LINK.  Could you fix it?  Thanks.

    Demian

  • mysterlund   Dec. 31, 2011, 7:47 a.m.
  • Anonym   Jan. 8, 2012, 12:16 a.m.
    In Reply To:   mysterlund   Dec. 31, 2011, 7:47 a.m.

    You need to group <h1> and <h2> together in the <hgroup> tag.  I noticed many people don't use it.  Maybe they don't know about the <hgroup> tag since it's a new feature in HTML5.

    Demian

  • crgb   Dec. 27, 2011, 5:11 p.m.
  • Nathan Day   Dec. 31, 2011, 9:59 a.m.
    In Reply To:   crgb   Dec. 27, 2011, 5:11 p.m.

    your second paragraph does not have <p></p> but still displays? is that tag not needed?

  • Anonym   Jan. 8, 2012, 12:29 a.m.
    In Reply To:   Nathan Day   Dec. 31, 2011, 9:59 a.m.

    You don't need a <p> tag to display the content.  The <p> tag inserts a paragraph in the document, which comes with its own top and bottom margins.  If you want to display the second paragraph as a paragraph, you should use the <p> tag.

    Demian

  • Anonym   Dec. 11, 2011, 3:49 p.m.

    http://dl.dropbox.com/u/3219051/index.html

  • alcinoe   Dec. 11, 2011, 4:54 p.m.
    In Reply To:   Anonym   Dec. 11, 2011, 3:49 p.m.
    Hi Oomoo, Nice start - don't forget to declare the doctype. Elizabeth
  • cwputer   Dec. 5, 2011, 9:42 p.m.

    My code:

     

    http://dl.dropbox.com/u/6904120/index.html

  • Robert Rivera   Dec. 5, 2011, 7:35 p.m.
  • Anonym   Jan. 8, 2012, 12:40 a.m.
    In Reply To:   Robert Rivera   Dec. 5, 2011, 7:35 p.m.

    Nice, clean code.  Good job smiley

    Demian

  • nzeribe   Dec. 4, 2011, 2:29 p.m.

    Here is my mark-up: a few lyrics from a Beatles song:

    http://jsfiddle.net/englebart/QWLDu/

  • leland   Nov. 25, 2011, 1:31 a.m.

    Here is my page! Decided to put it up on its own domain to make it official. Don't mind the comments about unicorns...

     

    http://typecurio.com/

  • alcinoe   Nov. 25, 2011, 1:48 a.m.
    In Reply To:   leland   Nov. 25, 2011, 1:31 a.m.

    I like your font, Leland.

  • Vita   Nov. 18, 2011, 10:57 a.m.

    So I decided to put all of the tasks in one HTML file, that way I won't get lost...wink

    http://dl.dropbox.com/u/18761433/HTML5Course/basicmarkup.html

    P.S. And of course I just couldn't leave it black and white, a bit fresher look won't hurt anyone!laugh

  • Peter Lord   Nov. 15, 2011, 9:30 a.m.
  • Richard   Nov. 7, 2011, 1:43 p.m.

    I still find this strange

    From Basic Markup:

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    <!DOCTYPE html>

    After the document type has been declared, we can go ahead and open our <html> tag, which will hold sub-elements of the document:

    <html>

    Be sure not to close the <html> tag yet, we will place the </html> tag at the end of the document.

    Now we will place the document header with a <head> tag. The <head> tag is a container for elements such as the page title, CSS for layout, and JavaScript for dynamic elements. This course does not cover those topics but there are study groups forming here at the School of Webcraft.

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The HTML5 doctype is <!Doctype html> so why declare an empty <html> tag below this?

    Surely this should have some attributes eg lang etc?

    For example    <html lang="en" class="no-js">

    Is this explained later on?

  • alcinoe   Nov. 14, 2011, 9:24 p.m.
    In Reply To:   Richard   Nov. 7, 2011, 1:43 p.m.

    I agree. This is just plain incorrect. 

  • Indie Media Project   Nov. 14, 2011, 9:47 p.m.
    In Reply To:   Richard   Nov. 7, 2011, 1:43 p.m.

    The <html> tag is the one which actually does the work in making the document html. If you were to leave out the doctype declaration you could still actually make a html file with just

    <html>

    <head>

    </head>

    <body>

    </body>

    </html>

    This is the basic markup for a page. You can start creating a page by inputting your <title> and <p> tags etc from here.

    Adding the doctype and attributes in your html i.e <html lang="en"> are the next steps in creating usable, standards compliant pages.

  • alcinoe   Nov. 15, 2011, 1:41 a.m.
    In Reply To:   Indie Media Project   Nov. 14, 2011, 9:47 p.m.

    That's fine if it is coming later.

  • Anonym   Nov. 15, 2011, 10:37 a.m.
    In Reply To:   Indie Media Project   Nov. 14, 2011, 9:47 p.m.

    I'm a bit confused.

    Are you saying that to create usable, standards compliant pages, I must have (for html5)

    <! DOCTYPE html>

    <html lang="en">?

    Do I need to include <meta charset="utf-8" /> also?

  • joe palmer   Nov. 15, 2011, 12:19 p.m.
    In Reply To:   Anonym   Nov. 15, 2011, 10:37 a.m.

    Right, everything is a building block that adds up.
     

    <!DOCTYPE html>
    <html lang="en">
    	<head>
    		<meta charset="utf-8">
    		<title>Hello World</title>
    	</head>
    	<body>
    		<h1>Hello World</h1>
    		<p>
    			You are here.
    		</p>
    	</body>
    </html>
    
    There is a good skeleton to memorize, it is everything you need to start a page.
    
    The parts I colored in just add function, but you want to try and commit to memory.
    This template without the colored parts is what you will use everytime. Really no need to understand charset just where it goes, it helps the device interpret and gives protection from what is called a cross script attack, the hacking of a site.
    When you see meta, think "more information here." 
    
    Here is an explanation of charset
    
    http://webdesign.about.com/od/metatags/qt/meta-charset.htm
    
    Also know that if your using Firefox, go ahead now and hold down the "cntrl" key and hit the "u" key,this will pop out a new window to view the HTML file your looking at, and do this looking at each others docs to see how things were done too. If you use a tool called Firebug it will let you change things in other peoples code to see what happens.
    
    http://getfirebug.com/
    
    
    
    

  • Anonym   Nov. 15, 2011, 3:20 p.m.
    In Reply To:   joe palmer   Nov. 15, 2011, 12:19 p.m.

    Thanks.  All is clear now smiley

  • alcinoe   Nov. 15, 2011, 5:53 p.m.
    In Reply To:   joe palmer   Nov. 15, 2011, 12:19 p.m.

    Thanks, Joe. That's very useful.

  • joe palmer   Nov. 15, 2011, 6:08 p.m.
    In Reply To:   alcinoe   Nov. 15, 2011, 5:53 p.m.

    Love seeing all the activity :)

  • Anonym   Nov. 7, 2011, 11:52 a.m.

    I have posted it here:

    http://pastebin.com/FcYwqpqZ

    I hope I did it correctly; I am looking forward to corrections and suggestions.