HTML – Important Questions & Answers UNIT 3

These answers include definitions, explanations, HTML syntax, examples, and complete programs. You can use them for exam preparation.

Q1. (a) Explain list tag and its types. How to create ordered list and unordered list? Explain with example. (5 Marks)

1. Definition of List in HTML

An HTML list is used to display related items in an organized manner.

HTML provides three main types of lists:

  1. Ordered List
  2. Unordered List
  3. Description List

2. Ordered List (<ol>)

An ordered list displays items in a specific order using numbers or letters.

Syntax:

<ol>
    <li>Apple</li>
    <li>Banana</li>
    <li>Mango</li>
</ol>

Output:

  1. Apple
  2. Banana
  3. Mango

Important attributes:

  • type="1" – Numbers (default).
  • type="A" – Capital letters.
  • type="a" – Small letters.
  • type="I" – Roman numbers.
  • type="i" – Small Roman numbers.
  • start="5" – Starts numbering from 5.

3. Unordered List (<ul>)

An unordered list displays items using bullet points instead of numbers.

Syntax:

<ul>
    <li>Orange</li>
    <li>Banana</li>
    <li>Mango</li>
</ul>

Output:

  • Orange
  • Banana
  • Mango

Bullet styles:

  • Disc – Filled circle.
  • Circle – Empty circle.
  • Square – Square bullet.

CSS can be used to change bullet styles.

4. Description List (<dl>)

A description list is used to display terms and their descriptions.

Example:

<dl>
    <dt>HTML</dt>
    <dd>HyperText Markup Language</dd>

    <dt>CSS</dt>
    <dd>Cascading Style Sheets</dd>
</dl>

Conclusion: HTML lists help organize information and make web pages easier to read.

Q1. (b) Divide a GIF image into two areas and create different hyperlinks for them. (5 Marks)

Definition

An image map is an HTML feature that allows different areas of a single image to have different hyperlinks.

We use the following tags:

  • <img> – Displays the image.
  • <map> – Defines an image map.
  • <area> – Defines clickable areas.

HTML Code

<!DOCTYPE html>
<html>
<head>
    <title>Image Map</title>
</head>
<body>

<h2>Clickable GIF Image</h2>

<img src="image.gif"
     width="400"
     height="200"
     usemap="#mymap"
     alt="Clickable GIF">

<map name="mymap">

    <area shape="rect"
          coords="0,0,200,200"
          href="https://www.google.com"
          alt="Google">

    <area shape="rect"
          coords="200,0,400,200"
          href="https://www.yahoo.com"
          alt="Yahoo">

</map>

</body>
</html>

Explanation

  1. image.gif is the GIF image displayed on the webpage.
  2. usemap="#mymap" connects the image with the image map.
  3. <map> defines the clickable areas.
  4. The first <area> creates a clickable left half.
  5. The second <area> creates a clickable right half.
  6. Clicking the left area opens Google.
  7. Clicking the right area opens Yahoo.

Note: The image is divided into two rectangular clickable areas of equal size.

Q1. (c) How to create row frames and column frames in HTML? (5 Marks)

Definition of Frames

Frames were used in older HTML to divide a browser window into multiple sections.

Each section could display a separate HTML document.

The <frameset> and <frame> tags were used to create frames.

Note: Frames are obsolete in HTML5. Modern websites use CSS layouts and <iframe> where appropriate.

1. Creating Row Frames

The rows attribute divides the browser window horizontally.

Example:

<html>
<head>
    <title>Row Frames</title>
</head>

<frameset rows="50%,50%">
    <frame src="top.html">
    <frame src="bottom.html">
</frameset>

</html>

Explanation:

  • rows="50%,50%" divides the browser window into two horizontal sections.
  • top.html is displayed in the upper section.
  • bottom.html is displayed in the lower section.

2. Creating Column Frames

The cols attribute divides the browser window vertically.

Example:

<html>
<head>
    <title>Column Frames</title>
</head>

<frameset cols="50%,50%">
    <frame src="left.html">
    <frame src="right.html">
</frameset>

</html>

Explanation:

  • cols="50%,50%" divides the browser window into two vertical sections.
  • left.html is displayed on the left side.
  • right.html is displayed on the right side.

Conclusion: The rows attribute creates horizontal frames, while the cols attribute creates vertical frames.

Q2. What is Form tag? Create an HTML form using Textfield, label, radiobutton and submit button. (15 Marks)

1. Definition of HTML Form

An HTML form is used to collect information from users and send it to a server for processing.

Forms are commonly used for registration, login, feedback, and contact pages.

The <form> tag is used to create an HTML form.

2. Important Form Elements

ElementPurpose
<form>Creates a form
<label>Provides a name for an input
<input type="text">Accepts text
<input type="radio">Allows selection of one option
<input type="submit">Submits the form

3. HTML Program

<!DOCTYPE html>
<html>
<head>
    <title>Student Form</title>
</head>

<body>

<h2>Student Registration Form</h2>

<form action="submit.php" method="post">

    <label for="name">Student Name:</label>
    <input type="text" id="name" name="name">
    <br><br>

    <label for="email">Email:</label>
    <input type="text" id="email" name="email">
    <br><br>

    <label>Gender:</label>

    <input type="radio"
           name="gender"
           value="Male">
    Male

    <input type="radio"
           name="gender"
           value="Female">
    Female

    <br><br>

    <input type="submit" value="Submit">

</form>

</body>
</html>

4. Explanation

  1. <form> creates the registration form.
  2. action="submit.php" specifies where the form data will be sent.
  3. method="post" sends the form data using the POST method.
  4. <label> displays the name of an input field.
  5. type="text" creates a text field.
  6. type="radio" creates a radio button.
  7. type="submit" creates a submit button.

Conclusion: HTML forms are used to collect user information and submit it to a server.

Q3. Write appropriate code in HTML to achieve the following. (15 Marks)

(i) Making an image clickable.

An image can be made clickable by placing the <img> tag inside the <a> tag.

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <title>Clickable Image</title>
</head>

<body>

<a href="https://www.google.com">
    <img src="photo.jpg"
         width="200"
         height="150"
         alt="Google">
</a>

</body>
</html>

Explanation:

  • <a> creates a hyperlink.
  • href specifies the destination.
  • <img> displays the image.
  • When the user clicks the image, Google opens.

(ii) Creating a table with two columns and two rows.

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <title>Student Table</title>
</head>

<body>

<table border="1">

    <tr>
        <th>Roll Number</th>
        <th>Name</th>
    </tr>

    <tr>
        <td>S101</td>
        <td>Ram</td>
    </tr>

    <tr>
        <td>S102</td>
        <td>Sham</td>
    </tr>

</table>

</body>
</html>

Output:

Roll NumberName
S101Ram
S102Sham

Explanation:

  • <table> creates a table.
  • <tr> creates a row.
  • <th> creates a heading cell.
  • <td> creates a normal data cell.
  • border="1" adds a border (legacy HTML; CSS is preferred today).

(iii) Making an unordered list containing Orange, Banana, Mango.

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <title>Fruit List</title>
</head>

<body>

<h2>Fruit Names</h2>

<ul>
    <li>Orange</li>
    <li>Banana</li>
    <li>Mango</li>
</ul>

</body>
</html>

Output:

  • Orange
  • Banana
  • Mango

Explanation:

  • <ul> creates an unordered list.
  • <li> defines each list item.

Q4. What is HTML? Explain HTML document structure with example.

1. Definition of HTML

HTML stands for HyperText Markup Language.

It is the standard markup language used to create and structure web pages.

HTML is used to add headings, paragraphs, images, links, tables, lists, and forms to a webpage.

2. Features of HTML

  1. Easy to learn and use.
  2. Platform independent.
  3. Supports images and multimedia.
  4. Supports hyperlinks.
  5. Supports tables and forms.
  6. Works with CSS and JavaScript.
  7. Supported by all major web browsers.

3. Basic Structure of an HTML Document

An HTML document contains the following main tags:

TagDescription
<!DOCTYPE html>Declares HTML5 document
<html>Root element
<head>Contains page information
<title>Defines webpage title
<body>Contains visible webpage content
<h1>Defines a main heading
<p>Defines a paragraph

4. HTML Document Example

<!DOCTYPE html>

<html>

<head>
    <title>My First Web Page</title>
</head>

<body>

    <h1>Welcome to HTML</h1>

    <p>
        HTML is used to create web pages.
    </p>

    <h2>About HTML</h2>

    <p>
        HTML stands for HyperText Markup Language.
    </p>

</body>

</html>

5. Explanation of HTML Structure

1. DOCTYPE Declaration

<!DOCTYPE html>

It tells the browser that the document uses HTML5.

2. HTML Tag

<html>
</html>

It is the root element of an HTML document.

3. Head Tag

<head>
    <title>My Page</title>
</head>

It contains information about the webpage.

4. Title Tag

<title>My First Web Page</title>

It defines the title shown in the browser tab.

5. Body Tag

<body>
    <h1>Welcome</h1>
    <p>Hello World</p>
</body>

It contains all the visible content of the webpage.

Conclusion: HTML provides the basic structure of a webpage and is the foundation of web development.

Q5. What is a form? What are the major attributes of the form? Explain any six form components with example.

1. Definition of Form

An HTML form is a section of a webpage used to collect information from users.

It allows users to enter data and send it to a server.

Examples: Login form, registration form, feedback form, and contact form.

2. Major Attributes of Form Tag

AttributeDescription
actionSpecifies where form data is sent
methodSpecifies GET or POST method
nameGives a name to the form
targetSpecifies where to display the response
enctypeSpecifies how form data is encoded
autocompleteEnables or disables automatic suggestions
novalidateDisables built-in form validation

Example:

<form action="submit.php"
      method="post"
      name="studentForm"
      autocomplete="on">

    Student Name:
    <input type="text" name="name">

    <input type="submit" value="Submit">

</form>

3. Six Important Form Components

1. Text Field

Used to enter a single line of text.

<label>Name:</label>
<input type="text" name="name">

2. Password Field

Used to enter a password. The entered characters are hidden visually.

<label>Password:</label>
<input type="password" name="password">

3. Radio Button

Used to select only one option from a group.

<label>Gender:</label>

<input type="radio" name="gender" value="Male">
Male

<input type="radio" name="gender" value="Female">
Female

4. Checkbox

Used to select one or more options.

<label>Hobbies:</label>

<input type="checkbox" name="hobby" value="Reading">
Reading

<input type="checkbox" name="hobby" value="Sports">
Sports

5. Textarea

Used to enter multiple lines of text.

<label>Address:</label>

<textarea name="address"
          rows="4"
          cols="30"></textarea>

6. Submit Button

Used to submit form data to the server.

<input type="submit" value="Submit">

4. Other Form Components

ComponentHTML Code
Email<input type="email">
Number<input type="number">
Date<input type="date">
File<input type="file">
Reset<input type="reset">
Dropdown<select>
Button<button>

Conclusion: HTML forms contain different input components that help collect information from users in an organized way.

Q6. Write HTML code to make a form for registration of students of your class. Consider at least 10 attributes of students and use appropriate buttons where required.

Student Registration Form

The following HTML program creates a student registration form containing more than ten student details.

HTML Code:


<!DOCTYPE html>
<html>
<head>
    <title>Student Registration Form</title>
</head>

<body>

<h2>Student Registration Form</h2>

<form action="register.php" method="post">

    <!-- Student Name -->
    <label>Student Name:</label>
    <input type="text" name="student_name" required>
    <br><br>

    <!-- Roll Number -->
    <label>Roll Number:</label>
    <input type="text" name="roll_number" required>
    <br><br>

    <!-- Father's Name -->
    <label>Father's Name:</label>
    <input type="text" name="father_name">
    <br><br>

    <!-- Mother's Name -->
    <label>Mother's Name:</label>
    <input type="text" name="mother_name">
    <br><br>

    <!-- Date of Birth -->
    <label>Date of Birth:</label>
    <input type="date" name="dob">
    <br><br>

    <!-- Gender -->
    <label>Gender:</label>
    <input type="radio" name="gender" value="Male">
    Male

    <input type="radio" name="gender" value="Female">
    Female
    <br><br>

    <!-- Email -->
    <label>Email:</label>
    <input type="email" name="email">
    <br><br>

    <!-- Mobile -->
    <label>Mobile Number:</label>
    <input type="tel" name="mobile">
    <br><br>

    <!-- Address -->
    <label>Address:</label>
    <textarea name="address" rows="3" cols="30"></textarea>
    <br><br>

    <!-- Course -->
    <label>Course:</label>
    <select name="course">
        <option value="">Select Course</option>
        <option value="BCA">BCA</option>
        <option value="MCA">MCA</option>
        <option value="BTech">B.Tech</option>
    </select>
    <br><br>

    <!-- Class -->
    <label>Class:</label>
    <input type="text" name="class">
    <br><br>

    <!-- City -->
    <label>City:</label>
    <input type="text" name="city">
    <br><br>

    <!-- Pincode -->
    <label>Pin Code:</label>
    <input type="text" name="pincode">
    <br><br>

    <!-- Buttons -->
    <input type="submit" value="Register">
    <input type="reset" value="Clear">

</form>

</body>
</html>

Explanation

The registration form contains the following student details:

  1. Student Name.
  2. Roll Number.
  3. Father’s Name.
  4. Mother’s Name.
  5. Date of Birth.
  6. Gender.
  7. Email Address.
  8. Mobile Number.
  9. Address.
  10. Course.
  11. Class.
  12. City.
  13. Pin Code.

Buttons used:

  • Register – Submits the form data.
  • Clear – Resets the form fields.

Conclusion: HTML forms help educational institutions collect student information digitally and systematically.

Q7. What is Table tag? Explain its attributes with example.

1. Definition of HTML Table

An HTML table is used to display data in rows and columns.

The <table> tag is used to create a table in HTML.

Tables are useful for displaying student records, marksheets, employee details, and product information.

2. Important HTML Table Tags

TagDescription
<table>Creates a table
<tr>Creates a table row
<th>Creates a heading cell
<td>Creates a data cell
<caption>Adds a table title
<thead>Groups table header rows
<tbody>Groups table body rows
<tfoot>Groups table footer rows

3. Important Table Attributes

AttributeDescription
borderSets the table border (legacy)
cellpaddingAdds space inside cells (legacy)
cellspacingSets space between cells (legacy)
widthSets table width
heightSets table height
colspanCombines multiple columns
rowspanCombines multiple rows
alignSets alignment (legacy)

Note: Many old table presentation attributes such as border, cellpadding, cellspacing, width, and align are obsolete in modern HTML. CSS is preferred for styling.

4. HTML Table Example

<!DOCTYPE html>
<html>
<head>
    <title>Student Table</title>
</head>

<body>

<h2>Student Details</h2>

<table border="1" cellpadding="10">

    <caption>Student Information</caption>

    <tr>
        <th>Roll Number</th>
        <th>Name</th>
        <th>Course</th>
    </tr>

    <tr>
        <td>101</td>
        <td>Ram</td>
        <td>BCA</td>
    </tr>

    <tr>
        <td>102</td>
        <td>Sham</td>
        <td>MCA</td>
    </tr>

</table>

</body>
</html>

5. Example of Colspan and Rowspan

Colspan: Used to combine two or more columns.

<table border="1">
    <tr>
        <th colspan="2">Student Details</th>
    </tr>

    <tr>
        <td>101</td>
        <td>Ram</td>
    </tr>
</table>

Rowspan: Used to combine two or more rows.

<table border="1">
    <tr>
        <td rowspan="2">BCA</td>
        <td>Ram</td>
    </tr>

    <tr>
        <td>Sham</td>
    </tr>
</table>

6. Modern Table Using CSS

<!DOCTYPE html>
<html>
<head>
<style>
table {
    border-collapse: collapse;
    width: 60%;
}

th, td {
    border: 1px solid black;
    padding: 10px;
    text-align: center;
}
</style>
</head>

<body>

<table>
    <tr>
        <th>Roll Number</th>
        <th>Name</th>
    </tr>

    <tr>
        <td>101</td>
        <td>Ram</td>
    </tr>
</table>

</body>
</html>

Conclusion: HTML tables organize data into rows and columns, making information easy to understand.

Q8. Explain and compare Hyperlink, Hypermedia and Hypertext with example.

1. Hyperlink

A hyperlink is a clickable text, image, or other element that takes the user from one web page or resource to another.

It is created using the <a> tag in HTML.

Example:

<a href="https://www.google.com">
    Visit Google
</a>

Explanation: When the user clicks “Visit Google”, the Google website opens.

Uses:

  • Connecting web pages.
  • Opening websites.
  • Downloading files.
  • Navigating between different sections.

2. Hypertext

Hypertext is text that contains links to other documents or information.

It allows users to move from one document to another by clicking linked text.

Example:

<p>
    Learn
    <a href="https://www.wikipedia.org">
        HTML
    </a>
    for web development.
</p>

Here, the word HTML is linked to another website.

Uses:

  • Online articles.
  • Educational websites.
  • Digital books.
  • Online documentation.

3. Hypermedia

Hypermedia is an extension of hypertext that connects different types of media, such as text, images, audio, video, and animation through links.

It allows users to interact with multimedia content.

Example:

<a href="video.html">
    <img src="video.jpg"
         width="200"
         alt="Watch Video">
</a>

Here, clicking the image opens a video page.

Uses:

  • Educational websites.
  • Multimedia presentations.
  • Online tutorials.
  • Interactive learning systems.
  • Digital libraries.

4. Difference Between Hyperlink, Hypertext, and Hypermedia

BasisHyperlinkHypertextHypermedia
MeaningClickable connectionText containing linksMultimedia content containing links
ContentText, image, or other elementMainly textText, images, audio, video
PurposeNavigationConnects text documentsConnects multimedia resources
ExampleClickable imageLinked word in an articleLinked video or image
UseWebsite navigationOnline articlesInteractive multimedia learning

5. Simple Example to Understand

Hyperlink

Click here to visit Google

A clickable link that opens another resource.

Hypertext
This is an article about HTML.

A word in the text links to another document.

Hypermedia

A multimedia element, such as an image or video, can connect to another resource.

Conclusion: A hyperlink creates a connection, hypertext connects text documents, and hypermedia connects different types of multimedia content.

Quick Revision – Important HTML Tags

HTML TagPurpose
<html>Defines HTML document
<head>Contains document information
<title>Sets webpage title
<body>Contains visible content
<h1> to <h6>Creates headings
<p>Creates paragraph
<a>Creates hyperlink
<img>Displays image
<ul>Creates unordered list
<ol>Creates ordered list
<li>Creates list item
<table>Creates table
<tr>Creates table row
<th>Creates table heading
<td>Creates table data
<form>Creates form
<input>Creates input field
<label>Creates input label
<textarea>Creates multiline text field
<select>Creates dropdown list
<option>Creates dropdown option
<button>Creates button
<map>Defines an image map
<area>Defines clickable image area

Important Exam Preparation Tips

Give special attention to these topics:

  1. HTML document structure – Learn the complete HTML program.
  2. HTML Lists – Practise ordered and unordered lists.
  3. HTML Forms – Learn text fields, radio buttons, checkboxes, and submit buttons.
  4. HTML Tables – Practise rowspan and colspan.
  5. Image Mapping – Understand how to create two clickable areas in one image.
  6. Hyperlink, Hypertext and Hypermedia – Learn their differences.
  7. Student Registration Form – Practise writing the complete program.

Practical tip: Save HTML programs with the .html extension, for example student.html, and open them in Google Chrome or another web browser to see the output.