HTML
HTML
HTML
Hyper
HTML
Hypertext
HTML
Hypertext

Markup
HTML
Hypertext

Markup

Language
Markup

This is text without markup.
Markup

This is text without markup.




<p>This is text <em>with</em> markup.</p>
Markup
It's just text!

 This is text without markup.




 <p>This is text <em>with</em> markup.</p>
HTML is XML
HTML is XML
eXtensible
HTML is XML
eXtensible

Markup
HTML is XML
eXtensible

Markup

Language
XML
      XML tags can be
        anything
HTML


   HTML uses a specific
      set of tags
Tags
<p>This paragraph has some <strong>bold
information</strong> in it.</p>




In the browser, this markup will look like:
This paragraph has some bold information in it.
Tags
<p>Lorem <strong><em>ipsum dolor</em></strong>
sit amet, consectetur elit.</p>




• Tags that open must close
• First one in, last one out
Nested tags
<div id="content">
  <p>This paragraph has some <strong>bold
  information</strong> in it.</p>
</div>




• Tags take a hierarchical, parent-child
  structure
The DOM
• Document Object Model
• Represents the nested structure of an
  HTML document
• Tree structure -- think family tree
                  body

      h1           ul          div
                                     p

                                         strong
The Skeletal System
Every page should have these tags:

• <html>
• <head>
• <title>
• <body>
A Simple Page
A Simple Page
<!DOCTYPE HTML>
A Simple Page
<!DOCTYPE HTML>
 <html>




</html>
A Simple Page
<!DOCTYPE HTML>
 <html>
   <head>


   </head>




</html>
A Simple Page
<!DOCTYPE HTML>
 <html>
   <head>
    <title>The name of my page</title>
   </head>




</html>
A Simple Page
<!DOCTYPE HTML>
 <html>
   <head>
    <title>The name of my page</title>
   </head>
   <body>


   </body>
</html>
A Simple Page
<!DOCTYPE HTML>
 <html>
   <head>
    <title>The name of my page</title>
   </head>
   <body>
    <p>Some information here.</p>
   </body>
</html>
In the Browser
Title



        Body
Doctype

• Tells the browser which version of HTML to
  use.
• In HTML 5, the doctype line is short:
  <!DOCTYPE HTML>
Head

• Provides information that isn't displayed in
  the body
• CSS and Javascript instructions are included
  here
Title


• Inside the <head> tag
• Titles the browser window
Body


• Everything to be displayed in the browser
• Most of the HTML goes here
Set-up

• Put the HTML into a text file using Text
  Wrangler, or the text editor of your
  choice.


• In Firefox, choose "File > Open File" and
  open your HTML page.
Exercise
Tags to Know
Paragraph


• <p>
• Creates a line break after closing tag
Line Breaks

• <br/>
• Closing slash inside tag because it doesn't
  enclose anything.
• Line breaks in the HTML text do not show
  up in the browser.
Bold and Italic


• <strong> and <em>
• The old way was to use <b> and <i>
Headings
<h1>,<h2>,<h3>, <h4>,<h5>,<h6>
Exercise
Create an outline in your HTML using headings and
paragraph tags.

Examples:
  •Table of Contents
  •Proposal
  •Presentation Notes
Links
   • <a>
   • The most important tag!


                                                     Link Text
      href                   URL
                                               What the link looks
Hyperlink Reference   Name of file to link to
                                               like in the browser
Links
   • <a>
   • The most important tag!
      <a href="page.html">Go to page</a>


                                                     Link Text
      href                   URL
                                               What the link looks
Hyperlink Reference   Name of file to link to
                                               like in the browser
Exercise
Create a new HTML page and link to it from your first
page.
Images
<img>




                                       Closing Slash
    src             URL
                                   Tag opens and closes
Image Source   Name of image file
                                      in the same tag
Images
<img>

          <img src="cats.jpg" />




                                         Closing Slash
    src               URL
                                     Tag opens and closes
Image Source     Name of image file
                                        in the same tag
Exercise
Add an image to your page.
Attributes
Extra information inside a tag, as in <a> and <img>
Attributes
Extra information inside a tag, as in <a> and <img>

   <a href="page.html">Go to page</a>
Attributes
Extra information inside a tag, as in <a> and <img>

   <a href="page.html">Go to page</a>


   <img src="cats.jpg" />
Attributes
Extra information inside a tag, as in <a> and <img>

   <a href="page.html">Go to page</a>


   <img src="cats.jpg" />


   <p class="highlight">My paragraph.</p>
Attributes
Extra information inside a tag, as in <a> and <img>

   <a href="page.html">Go to page</a>


   <img src="cats.jpg" />


   <p class="highlight">My paragraph.</p>


   <div id="navigation">My navigation</div>
Inline vs. Block
           Elements
• Block-level elements begin a new line in the
  flow of a page.
• Inline elements stay in the current flow of
  the page without breaking a line.

         Block               Inline

           <p>               <img>
          <h1>              <strong>
         <table>             <em>
          <div>              <span>
Lists

• <ol> : Ordered list, usually with numbers
• <ul> : Unordered list, with bullets
• <li> : List item -- each item in list
• <ul> or <ol> tags wrap a set of <li> tags
Unordered List
Ordered List
Exercise
Create a site navigation using the <ul> and <li> tags.

Don't forget the link (<a>) tags!
Tables

• <table> : open and close a table
• <tr> : table row
• <td> : table data, aka a cell
• <th> : table heading
Building Tables

<tr>   Jane   555-9871   San Francisco

       John   555-0862     San Jose

       Judy   555-9753   Mountain View
<td>
Building Tables
  <table>
  <tr>
     <td>Jane</td>
     <td>555-9871</td>
     <td>San Francisco</td>
  </tr>
  ...


</table>
Exercise
Create a table in HTML
The <div> tag

• Used to group elements semantically, by
  topic
• Useful for layout with CSS
• Will usually have an id or class attribute to
  identify it
Using <div>
         Divs identify
        sections of the
          document
The <span> tag
• Like div, helps organize code
• Inline element
• Used for smaller pieces of code than div
The <span> tag
• Like div, helps organize code
• Inline element
• Used for smaller pieces of code than div
<p>Some of <span class="highlight">this
text</span> is not like the other</p>
Exercise
Add sections to your HTML document using div tags
with id attributes

Html intro