Web Technology I · Unit 2
HTML Basics and Structure
Exam-focused notes for HTML Basics and Structure (Web Technology I, BIT251): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
HTML Basics and Structure in short
HTML gives every web page its structure. This chapter covers the basic skeleton of a page and the tags that give meaning to each part. Good structure helps browsers, search engines and screen readers.
What this unit covers
- HTML head and body tags
- HTML title and meta tags
- HTML semantic elements
- Main and article tags
- Aside tag usage
- Figure tag with captions
HTML head and body tags
2080 · 10 marks
Define HTML head and body tags. Write HTML script to display following output. The title of the page should be 'BIT Web Tech'.[10]
Show solved answerHide answer
HTML Head and Body Tags
Definition
<head> Tag
The <head> tag is a container element that holds meta-information about the HTML document. The content inside the <head> tag is not displayed directly on the web page. It contains elements such as:
<title>- defines the title of the page (shown in browser tab)<meta>- provides metadata like charset, author, description<link>- links external stylesheets<style>- contains internal CSS<script>- contains or links JavaScript
Syntax:
<head>
<!-- meta information goes here -->
</head>
<body> Tag
The <body> tag defines the main content of the HTML document that is visible to the user in the browser window. It contains all the displayable content such as:
- Headings, paragraphs, images, links, tables, lists, forms, etc.
Syntax:
<body>
<!-- visible content goes here -->
</body>
HTML Script
Note: Since no image of the required output was provided, the following is a commonly expected output for this type of question in TU BScCSIT/BIT exams, featuring a heading, a table, and a list. Adjust content if your question had a specific screenshot.
<!DOCTYPE html>
<html>
<head>
<title>BIT Web Tech</title>
</head>
<body bgcolor="lightblue">
<h1 align="center">Welcome to BIT Web Tech</h1>
<hr>
<h2>Course Information</h2>
<table border="1" cellpadding="5" cellspacing="0">
<tr bgcolor="yellow">
<th>S.N.</th>
<th>Course Name</th>
<th>Credit Hour</th>
</tr>
<tr>
<td>1</td>
<td>Web Technology</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>Database Management</td>
<td>3</td>
</tr>
<tr>
<td>3</td>
<td>Programming in C</td>
<td>3</td>
</tr>
</table>
<h2>Key Features</h2>
<ul>
<li>HTML and CSS</li>
<li>JavaScript</li>
<li>PHP and MySQL</li>
</ul>
<h2>Semester List</h2>
<ol>
<li>First Semester</li>
<li>Second Semester</li>
<li>Third Semester</li>
</ol>
<hr>
<p align="center">
<b>Contact us at:</b>
<a href="mailto:[email protected]">[email protected]</a>
</p>
</body>
</html>
Expected Browser Output
| Element | Description |
|---|---|
| Browser Tab | Shows BIT Web Tech |
| Page Heading | "Welcome to BIT Web Tech" centered |
| Table | Course information with border |
| Unordered List | Key features with bullet points |
| Ordered List | Semester list with numbers |
| Footer | Contact email as hyperlink |
Summary Table of Head vs Body
| Feature | <head> | <body> |
|---|---|---|
| Visibility | Not visible to user | Visible to user |
| Contains | Title, meta, style, script | Text, images, tables, forms |
| Purpose | Document information | Document content |
| Required | Yes | Yes |
Main and article tags
2081 · 5 marks
What are the usages of Main and Aside tags? Write HTML script using these tags. [3+2]
Show solved answerHide answer
Main and Aside Tags in HTML
Usages of <main> Tag
The <main> tag is used to specify the main content of a document. It represents the dominant content of the <body> of a document.
Key points:
- There should be only one
<main>element in a document - The content inside
<main>should be unique to the document - It helps screen readers and search engines identify the primary content
- It excludes content that is repeated across pages like navigation bars, headers, footers, and sidebars
Usages of <aside> Tag
The <aside> tag is used to define content that is placed aside from the main content. It represents content that is indirectly related to the surrounding content.
Key points:
- Used for sidebars, pull quotes, advertisements, or related links
- The content inside
<aside>is tangentially related to the main content - It is often displayed as a sidebar in a webpage
- Helps in semantic structuring of the webpage
HTML Script Using <main> and <aside> Tags
<!DOCTYPE html>
<html>
<head>
<title>Main and Aside Example</title>
<style>
main {
width: 70%;
float: left;
background-color: #f0f0f0;
padding: 10px;
}
aside {
width: 25%;
float: right;
background-color: #d0e4f7;
padding: 10px;
}
</style>
</head>
<body>
<header>
<h1>My Website</h1>
</header>
<main>
<h2>Welcome to the Main Content</h2>
<p>
This is the primary content of the webpage.
It contains the most important information
that the user is looking for.
</p>
<p>
HTML5 semantic tags help organize content
in a meaningful and accessible way.
</p>
</main>
<aside>
<h3>Related Links</h3>
<ul>
<li><a href="#">HTML Tutorial</a></li>
<li><a href="#">CSS Tutorial</a></li>
<li><a href="#">JavaScript Guide</a></li>
</ul>
<h3>Advertisement</h3>
<p>Buy our new book on Web Development!</p>
</aside>
<footer style="clear:both;">
<p>Copyright 2024. All rights reserved.</p>
</footer>
</body>
</html>
Output Structure
| Section | Tag Used | Purpose |
|---|---|---|
| Primary content area | <main> | Holds the main article/content |
| Sidebar area | <aside> | Holds related links and ads |
2080.2 · 5 marks
Write HTML script to demonstrate use of the main and article tags. [5]
Figure tag with captions
2080 · 5 marks
Write HTML script to markup photo in an HTML document using figure tag. The source path of the photo is D:\BIT\CAMPUS.JPEG. Set the alternate text to 'BIT'. The caption of the figure should be 'This is the BIT Campus'. [5]
HTML title and meta tags
2080.2 · 5 marks
Create an HTML page that contains Meta tag. Set the title of your page to "This Meta BIT". Set the description content in Meta to "Hello BIT", Keyword contents to "BIT", "IOST", "TU" and character encoding to "UTF-8". Also write "Hello BIT" and "Web Tech" in H1 and H2 tag under body section of the page. [5]
Make Unit 2 stick
Practice BIT251 with flashcards & quizzes