CHS Web Design Track

Tutorial 1 Getting Started with HTML5

<< Previous Lesson | Next Lesson >>

Session 1.1 Visual Overview:

Objectives

  • Explore the history of the web
  • Create the structure of an HTML document
  • Insert HTML elements and attributes
  • Insert metadata into a document
  • Define a page title
  • Mark page structures with sectioning elements
  • Organize page content with grouping elements
  • Mark content with text-level elements
  • Insert inline images
  • Insert symbols based on character codes
  • Mark content using lists
  • Create a navigation list
  • Link to files within a website with hypertext links
  • Link to e-mail addresses and telephone numbers
  • The Structure of an HTML5 Document

The Structure of an HTML5 Document

Exploring the World Wide Web

Network
A network is a structure in which information and services are shared among devices
Host or a node
A host or a node can be any device that is capable of sending and/or receiving data electronically
Server
A server is a host that provides information or a service to other devices on the network
Client
A computer or other device that receives a service is called a client
Client-server network
In a client-server network, clients access information provided by one or more users
Local area network
A network confined to a small geographic area, such as within a building or department
Wide Area Network (WAN)
A network that covers a wide area, such as several buildings or cities, is called a wide area network (WAN)
Hypertext
is a method of organization in which data sources are interconnected through a series of links or hyperlinks that users can activate to jump from one piece of information to another

Web Pages and Web Servers

Web page
Each document on the web is referred to as a web page
web servers
Web pages are stored on web servers
Web browser
Documents on the web are accessed through a software program called a web browser

Introducing HTML

HTML (Hypertext Markup Language)
A Web page is a text file written in HTML (Hypertext Markup Language)
Markup language
A markup language describes the content and structure of a document by identifying, or tagging, different document elements

The History of HTML

Tools for Working with HTML

Virsion Date Description
HTML 1.0 1989 The first public version of HTML
HTML 2.0 1995 HTML version that added interactive elements including web forms
HTML 3.2 1997 HTML version that provided additional support for web tables and expanded the options for interactive form elements and a scripting language
HTML 4.01 1999 HTML version that added support for style sheets to give web designers greater control over page layout and appearance, and provided support for multimedia elements such as audio and video
XHTML 1.0 2001 A reformulation of HTML 4.01 using the XML markup language in order to provide enforceable standards for HTML content and to allow HTML to interact with other XML languages
XHTML 2.0 discontinued in 2009 The follow-up version to XHTML 1.1 designed to fix some of the problems inherent in HTML 4.01 syntax
HTML 5.0 2012 The current HTML version providing support for mobile design, semantic page elements, column layout, form validation, offline storage, and enhanced multimedia
IDE (Integrated Development Environment)
A software package that provides comprehensive coverage of all phases of the development process from writing HTML code to creating scripts for programs running on web servers
Validators
are programs that test code to ensure that it contains no syntax errors

Exploring an HTML File

Figure 1-4 The Curbside Thai starting page as rendered by a mobile and tablet device
To open the ct_start.html file:
  1. Use the editor of your choice to open the ct_start.html file from the html01 > tutorial folder.
  2. Scroll through the document to become familiar with its content but do not make any changes to the text.
Figure 1-2 shows the complete contents of the file as viewed in the Notepad++ editor. Trouble? Depending on your editor and its configuration, the text style applied to your code might not match that shown in Figure 1-2. This is not a problem. Because HTML documents are simple text files, any text styles are a feature of the editor and have no impact on how the document is rendered by the browser.

The Document Type Declaration

The first line in an HTML file is the document type declaration, or doctype, that indicates the type of markup language used in the document

<!DOCTYPE html>

Introducing Element Tags

Element
tag is the fundamental building block in every HTML document that marks an element in the document
A starting tag (<element>)
indicates the beginning of an element
Ending tag (</element>)
indicates the ending

The general syntax of a two-sided element tag is:

<element>content</element>

The following code marks a paragraph element

<p>Welcome to Curbside Thai.</p>
Empty elements
are elements that are either nontextual (images) or contain directives to the browser about how the page should be treated

− For example, <br /> is used to indicate the presence of a line break in the text

The Element Hierarchy

<!DOCTYPE html> 
<html> 
    <head> 
        head content 
    </head> 
    <body> 
        body content 
    </body> 
</html>

Introducing Element Attributes

Element attributes
provide additional information to the browser about the purpose of the element
The general syntax of an element attribute
<element attr1=”value1” attr2=”value2” ...> content</element>
where attr1, attr2, etc. are the names of attributes associated with the element and value1, value2, etc., are the attribute values

Handling White Space

Viewing HTML File in a Browser

To open the ct_start.html file in a web browser:
  1. Open your web browser. You do not need to be connected to the Internet to view local files stored on your computer.
  2. After your browser loads its home page, open the ct_start.html file from the html01 > tutorial folder.
  3. Reduce the width of your browser window and note that when the width falls below a certain value (in this case 480 pixels), the layout automatically changes to a stacked row of images (as shown in the mobile device image in Figure 1-4) that are better suited to the narrower layout.
  4. Increase the width of the browser window and confirm that the layout changes to a 2x3 grid of images (as shown in the tablet device image in Figure 1-4), which is a design more appropriate for the wider window.
Figure 1-4 shows the page as it appears on a mobile phone and on a tablet device. The two devices have different screen widths, which affects how the page is rendered.
Trouble? If you're not sure how to open a local file with your browser, check for an Open or Open File command under the browser's File menu. You can also open a file by double-clicking the file name from within Windows Explorer or Apple Finder.
 
To begin writing the HTML file:
  1. Using the editor of your choice, create a new blank HTML file in the html01 > tutorial folder, saving the file as ct_about.html.
  2. Enter the following code into the file:
    <!DOCTYPE html>
    <html>
        <head>
        </head>
        <body>
        </body>
    </html>
                            
  3. Save your changes to the file.
Figure 1-5 shows the initial elements in the document.
  • HTML describes a document's content and structure, but not its appearance
  • The actual appearance of the document is determined by style sheets

Creating the Document Head

  • The document head contains metadata
  • Metadata is the content that describes or provides information about how the document should be processed by the browser
Element Description
head Contains a collection of metadata elements that describe the document or provide instructions to the browser
base Specifies the document's location for use with resolving relative hypertext links
link Specifies an external resource that the document is connected to
meta Provides a generic list of metadata values such as search keywords, viewport properties, and the file's character encoding
script Provides programming code for programs to be run within the document
style Defines the display styles used to render the document content
title Stores the document's title or name, usually displayed in the browser title bar or on a browser tab

Setting the Page Title

To insert the document title:
  1. Directly after the opening tag, insert the following title element, indented to make the code easier to read.
    <title>About Curbside Thai</title>
  2. Save your changes to the file.
Figure 1-7 highlights the code for the page title.

Adding Metadata to the Document

Meta
element is used for general lists of metadata values. The meta element structure is <meta attributes />
Character encoding
is the process by which a computer converts text into a sequence of bytes and vice versa when it stores the text and when the text is read
Attribute Description
charset=”encoding” Specifies the character encoding used in the HTML document [HTML5]
content=”text” Provides the value associated with the http-equiv or name attributes
http-equiv=”content-type|default-style|refresh” Provides an HTTP header for the document's content, default style, or refresh interval (in seconds)
name=”text” Sets the name associated with the metadata
 
To insert metadata:
  1. Directly after the opening <head> tag, insert the following meta elements, indented to make the code easier to read:
    <meta charset=”utf-8” /> 
    <meta name=”keywords” content=”Thai, restaurant, Charlotte, food” />
  2. Save your changes to the file.
  3. Open the ct_about.html file in your browser. Confirm that the browser tab or rowser title bar contains the text “About Curbside Thai”. There should be no text displayed in the browser window because you have not added any content to the page body yet.
Figure 1-9 highlights the newly added meta elements used in the document head.

Adding Comments to Your Document

Comment
A comment is descriptive text that is added to the HTML file but does not appear in the browser window <!--comment -->
To add a comment to the document:
  1. Return to the ct_about.html file in your HTML editor.
  2. Directly after the opening <head> tag, insert the following comment text, indented to make the code easier to read:
    <!-- 
        New Perspectives on HTML5 and CSS3, 7th Edition  Tutorial 1 
        Tutorial Case 
        General Information about Curbside Thai  Author: your name 
        Date:   the date 
        Filename: ct_about.html 
        -->
    where your name is your name and the date is the current date. Figure 1-10 highlights the newly added comment in the file
  3. Save your changes to the file.

Session 1.1 Quick Check

  1. What is a markup language?
  2. What is XHTML? How does XHTML differ from HTML?
  3. What is the W3C? What is the WHATWG?
  4. What is a doctype? What is the doctype for an HTML5 document?
  5. What is incorrect about the following code? Suggest a possible revision of the code to correct the error.
    <p><strong>Curbside Thai now delivers!</p></strong>
  6. Provide code to mark Curbside Thai Employment Opportunities as the document title.
  7. Provide code to create metadata adding the keywords food truck, North Carolina, and dining to the document.
  8. Provide code to tell the browser that the character encoding UTF-16 is used in the document.
  9. Provide code to add the comment Created by Sajja Adulet to the document.
<< Previous Lesson | Next Lesson >>