Unit 2 - HTML for Content Structure
Unit 2 - HTML for Content Structure
This unit begins by introducing essential HTML tags and their functions. You'll learn
how these tags help create different sections of a webpage, such as the head, body, and footer.
By the end of this unit, you will be equipped to build basic web pages, understand the
significance of file extensions and naming conventions, and follow best practices for saving
and organizing HTML files. Additionally, you'll explore how to view your HTML pages across
different web browsers to ensure compatibility and consistency.
Learning Objectives
Pre-Test 2
Web Page Builder Challenge
Directions: In this activity, students are tasked to build a web page, organize their files
correctly, and test it for compatibility across multiple browsers. As they advance, students
engage in an interactive experience while learning HTML and web design.
Execution:
• In this activity, students will work individually. They will complete the tasks and
answer questions using any text editor available on their PC. Afterward, each student
will present their output to the class and receive feedback.
Task 1: Create a basic web page that includes your personal information. Your task is to
include the following sections:
Head: Add a title that will describe your web page.
Body: Structure the content using basic HTML tags (heading, paragraph, etc.) and use
appropriate HTML tags for each element.
Footer: Include copyright information for the footer.
Task 2: Save your file using the .html as the extension. Use proper naming conventions for
your files.
Task 3: Test your web page across at least three different browsers. Check if your page
displays correctly on each one, and note any issues or layout discrepancies you encounter.
Task 4: Share your experience with your classmate during the cross-browser testing. What
problems did you face and how did you fix them.
Lesson Proper
Structural Elements
Understanding the basic structure of a web page is crucial before embarking on web
development. A web page is typically organized into a few fundamental components that
define its layout and content. The structure begins with the <!DOCTYPE html> declaration,
which informs the browser about the version of HTML used in the document. Following this
are the <html></html> tag pairs, which serve as the root element encompassing all other
HTML elements. Within the <html></html> tag pairs, the web page is divided into two
primary sections: the <head> and the <body>. The <head> section contains meta-information
such as the title of the document, links to external stylesheets, scripts, and other metadata
that help configure the document’s behavior and appearance but do not appear directly on
the page.
The <body> section is where the main content of the web page resides. This includes
text, images, videos, links, and any interactive elements that the user can engage with. Proper
structuring within the <body> is essential to ensure content is well-organized and accessible.
Developers use various HTML tags such as headings (<h1> to <h6>), paragraphs (<p>), lists,
and sections like <header>, <footer>, and <main> to logically organize content and provide a
clear layout. Understanding this basic structure is fundamental to creating web pages that are
not only visually appealing but also functional and user-friendly. It ensures that the content
is appropriately displayed and enhances the overall user experience.
To begin creating a web page, you will need a text editor or a source code editor
installed on your computer. You can use simple tools like Notepad, or more advanced editors
such as Sublime Text or Notepad++. The first step is to open your chosen editor and create a
new file. It's a good practice to save this file before you start writing your HTML code. When
saving, make sure to choose the "Save As" option, and save the file with an .html extension
(e.g., mypage.html). This tells the computer that the file is an HTML document.
Once your file is saved, you can begin writing your HTML code inside the editor. After
you've written your code, you can view the results by simply double-clicking on the saved
HTML file. This action will open the file in your default web browser, displaying the contents
as a web page. It's important to note that since this file is saved on your local computer and
not hosted on a web server, only you can view it. Other users won’t be able to access your file
unless it is uploaded to a web server. This local setup is perfect for learning and testing your
web pages before making them available online.
Proper organization of HTML files is essential for efficient web development and long-
term project maintenance. When working on a web project, it's important to establish a clear
directory structure. Typically, you should have separate folders for different types of files,
such as images for all your graphics, css for stylesheets, and js for JavaScript files. This
structure helps in keeping your project organized, making it easier to find and update specific
files. A well-organized project not only saves time but also reduces the likelihood of errors,
especially in larger projects.
In addition to folder organization, consistent and descriptive naming conventions are
crucial. File names should be meaningful and reflect their content or purpose. For example,
instead of naming a file page1.html, use a more descriptive name like about-us.html. Avoid
using spaces in file names; instead, use hyphens or underscores. Also, maintain a consistent
case (preferably lowercase) throughout your project. Following these practices will make
your project more manageable, especially when working in teams or when revisiting the
project after some time.
Now that you have successfully created, saved, and displayed an HTML file, it's
important to delve deeper into its contents to understand the fundamental building blocks.
Every HTML file is structured using specific tags that define the overall framework of the
webpage. HTML tags are special keywords enclosed within angle brackets, such as <html>.
These tags usually come in pairs, with a start tag (e.g., <body>) and an end tag (e.g.,
</body>). The start tag opens the element, while the end tag closes it, enclosing the content
in between. Tags like <br /> or <hr /> are self-closing and do not require an end tag.
The first tag in any HTML file is the <!DOCTYPE html> declaration, which tells the
browser that the document follows HTML5 standards. This declaration ensures that your
webpage is rendered correctly. Following the <!DOCTYPE> declaration, the <html> and
</html> tags encapsulate the entire HTML document, marking its start and end. Inside these
tags, the document is typically divided into two main sections: the <head> section, which
contains metadata, links to stylesheets, and scripts, and the <body> section, which holds the
actual content visible on the webpage. For consistency and best practices, it's recommended
to use lowercase letters for all tags, as this aligns with modern web standards. Here’s what
the basic structure should look like:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Your Name - Personal Website</title>
</head>
<body>
<!--Your content goes here -->
</body>
</html>
The <meta> element in HTML is used to provide metadata about a web page, which
can include information such as the character encoding, author, description, keywords, and
viewport settings. It is typically placed within the <head> section of the HTML document. The
<meta> tag does not affect the content displayed on the page but plays a crucial role in
enhancing SEO (Search Engine Optimization), improving page rendering, and ensuring
proper accessibility. Common attributes of the <meta> tag include name, content, http-equiv,
and charset. For example, setting the charset attribute ensures the correct encoding of the
text, while the name="viewport" attribute is essential for responsive web design. Overall, the
<meta> element allows web developers to configure how their page is interpreted by
browsers and search engines.
The HTML comment element, represented by <!-- comment here -->, is used to
insert comments within an HTML document. These comments are not displayed in the
browser, but they provide valuable information for developers, such as explanations, notes,
or reminders within the code. HTML comments can span multiple lines and help improve
code readability and maintainability, especially when working in teams or revisiting code
after some time. They can also be used to temporarily disable code without deleting it.
However, it is important to note that comments are visible in the page's source code, so
sensitive information should never be placed within them. Overall, HTML comments serve as
an effective tool for documentation and collaboration during web development.
To display a webpage's title in the browser's tab, the <title></title> tag pairs
are used within the <head> section. The title provides a brief description of the page's content
and is essential for user navigation and SEO. For content structuring, paragraphs are created
using the <p></p> tag pairs, which helps in formatting text into distinct blocks. Additionally,
line breaks can be inserted using the <br /> tag to control the flow of text. For styling, the
<b> and <i> tags are used to apply bold and italic formatting, respectively. Proper use of
these tags ensures your content is organized, readable, and visually appealing.
Headings are another crucial aspect of content structuring, defined by tags ranging
from <h1> to <h6>, with <h1> representing the largest and most important heading and
<h6> the smallest. Headings help organize content hierarchically, making it easier for users
to navigate. Lastly, horizontal rules, created using the <hr /> tag, provide a visual separation
between sections of content, enhancing readability and structure. By understanding and
properly applying these tags, you can create well-structured, visually coherent web pages.
Seatwork 2
Name: ___________________________________________ Score: __________________
Year/Section: ____________________________________ Date: ___________________
Directions: Read each question carefully and select the correct answer by encircling the
corresponding letter. Any form of erasure will invalidate your answer.
a. <html></html>
b. <body></body>
c. <head></head>
d. <root></root>
3. Where is the <title> tag typically placed in an HTML document?
a. Inside the <body> section
b. Inside the <head> section
c. Inside the <footer> section
d. At the end of the document
4. Which tag is used to create a paragraph in HTML?
a. <p></p>
b. <div></div>
c. <section></section>
d. <article></article>
5. What is the correct tag to create a heading in HTML?
a. <head>
b. <h1> through <h6>
c. <heading>
d. <hgroup>
6. What tag is used to add a horizontal line in an HTML page?
a. <line />
b. <hr />
c. <hline />
d. <br />
7. Which tag is used to create a line break in HTML?
a. <break />
b. <br />
c. <lb />
d. <line />
8. What should the file extension of an HTML file be?
a. .html
b. .htm
c. .docx
d. .css
9. What is the correct syntax to begin an HTML document?
a. <html><head><body></body></html>
b. <!DOCTYPE html><html><head></head><body></body></html>
c. <html><body><head></body></html>
d. <html><body></html><head></body>
a. <header>
b. <footer>
c. <body></body>
d. <main>
16. What is the function of the <html> tag in an HTML document?
a. It defines the metadata of the page
b. It defines the body of the page
c. It is the root element that contains all other HTML elements
d. It is used to add links to external stylesheets
17. Which of the following is the correct way to add a comment in HTML?
a. // This is a comment
b. <!-- This is a comment -->
c. /* This is a comment */
d. # This is a comment
18. How do you ensure that your HTML file is compatible across different browsers?
a. Test the webpage on multiple browsers and devices
b. Use only one browser for testing
c. Avoid using JavaScript in the HTML file
d. Use external libraries that are not browser-specific
19. What should the HTML file structure begin with to ensure it adheres to the HTML5
standard?
a. <!DOCTYPE html>
b. <meta charset="UTF-8">
c. <html lang="en">
d. <head></head>
20. Where would you typically include the external CSS files in an HTML document?
a. Inside the <body> section
b. Inside the <head> section using the <link> tag
c. Inside the <footer> section
d. Inside the <header> section
Laboratory Exercise 2
Building a Basic HTML Web Page
Name: ___________________________________________ Score: __________________
1. Using a Source Code Editor, create an HTML file that will produce the same output as
shown below.
3. Open your text editor (e.g., Notepad, Sublime Text, Visual Studio Code).
5. Write the basic structure of the HTML document. You may consider this as a template.
6. Open your website in at least three different browsers (Google Chrome, Mozilla
Firefox, Microsoft Edge).
7. Check if all elements appear correctly. Identify any issues with layout or text
alignment that may differ between browsers.
Outcome: By completing this exercise, you will have created a personal website that displays
your bio, portfolio, and contact information. You will also practice organizing HTML files,
using basic HTML tags, and ensuring browser compatibility. This simple personal website can
serve as a portfolio or an introduction to potential audiences or collaborators.