2 Html Basics And Structure

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.

HTML Basics and Structure: notes

HTML head and body tags

Every HTML page has a root <html> element with two children: <head> and <body>. The head holds information about the page that is not shown directly. The body holds everything the user sees.

  • The head can contain <title>, <meta>, <link>, <style> and <script>.
  • The body can contain headings, paragraphs, images, links, tables and forms.
  • <!DOCTYPE html> on the first line tells the browser to use HTML5.
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My Page</title>
</head>
<body>
  <h1>Hello</h1>
  <p>This is my first page.</p>
</body>
</html>

HTML title and meta tags

The <title> tag sets the text shown on the browser tab. Search engines also use it as the page link text in results. It must be inside the head and each page should have its own title.

The <meta> tag gives metadata, which is data about the page. It is an empty tag with no closing tag.

  • charset sets the character encoding, usually UTF-8.
  • name="description" gives a short summary for search engines.
  • name="keywords" lists keywords. Search engines now mostly ignore it.
  • name="author" names the writer.
  • name="viewport" makes the page fit mobile screens.
  • http-equiv="refresh" can reload or redirect the page after some seconds.
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Notes on web technology">
  <meta name="author" content="A. Student">
  <title>Web Technology Notes</title>
</head>

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

2081 · 5 marks

Write HTML script to generate following output. [5]

Since no specific output image is provided, I will create a commonly asked HTML table output in TU BSc CSIT exams: a formatted table with merged cells (colspan/rowspan), which is the standard 5-mark HTML question pattern. --- A table like: College Information ------ Name TU Faculty CSIT Semester ...

Open this answer on its own page →

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 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

ElementDescription
Browser TabShows BIT Web Tech
Page Heading"Welcome to BIT Web Tech" centered
TableCourse information with border
Unordered ListKey features with bullet points
Ordered ListSemester list with numbers
FooterContact email as hyperlink

Summary Table of Head vs Body

Feature<head><body>
VisibilityNot visible to userVisible to user
ContainsTitle, meta, style, scriptText, images, tables, forms
PurposeDocument informationDocument content
RequiredYesYes
Open this answer on its own page →

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 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

SectionTag UsedPurpose
Primary content area<main>Holds the main article/content
Sidebar area<aside>Holds related links and ads
Open this answer on its own page →

2080.2 · 5 marks

Write HTML script to demonstrate use of the main and article tags. [5]

  • <main tag: Represents the dominant/main content of the <body of a document. There should be only one <main element per page. - <article tag: Represents a self-contained, independent piece of content that can be distributed or reused independently (e.g., a blog post, news article, forum post). -...
Open this answer on its own page →

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]

The <figure tag in HTML is used to mark up self-contained content such as images, diagrams, or photos. The <figcaption tag is used inside <figure to provide a caption for the content. --- --- Tag / Attribute Purpose ------ <figure Defines a self-contained block for the image content <img Embeds t...

Open this answer on its own page →

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]

--- Tag / Attribute Purpose ------ <!DOCTYPE html Declares the document as HTML5 <meta charset="UTF-8" Sets character encoding to UTF-8 <meta name="description" content="Hello BIT" Sets the page description to "Hello BIT" <meta name="keywords" content="BIT, IOST, TU" Sets keywords: BIT, IOST, TU ...

Open this answer on its own page →