HTML SA Solution
HTML SA Solution
<html>
<head>
"Welcome"
</head>
<body>
"User"
</body>
</html>
a) "Welcome""User"
b) Welcome User
c) "User"
d) no output due to incorrect markup
Explanation:
HTML is a markup language used to structure web pages. It has predefined semantic
tags like <head> and <body>, each serving a specific purpose.
The <body> tag contains everything you want visible on the page — this is the part
that actually gets rendered in the browser window.
• "Welcome" is placed inside the <head> section, which is not rendered visually.
• "User" is inside the <body>, which is rendered by the browser.
Therefore, the only visible content when this HTML page loads will be:
"User"
Key Points to Remember:
Exam Tip:
Always distinguish between the structural purpose of <head> and <body>. Only <body>
content appears in the rendered web page.
✅ Question 2
Renny has created an HTML page containing a link to navigate to demo.html page.
When the link is clicked, she wants the demo.html page to open in a new tab. What can
be used to achieve this?
Options:
Explanation:
HTML's <a> tag is used to create hyperlinks. The target attribute specifies where to open
the linked document.
Option a: target="_top"
Incorrect – opens in full window, not a new tab.
Option c: action="new"
Incorrect – action is used in <form> tags, not in <a>.
Option d: target="_blank"
Correct – opens the linked page in a new tab, which is what is required.
Exam Tip:
Use target="_blank" when you want links to open in new tabs. It's commonly used for
external links or additional resources.
✅ Question 3
Options:
Explanation:
The pattern attribute in HTML is used to define a regular expression that the <input>
element’s value is checked against when the form is submitted.
• The pattern attribute works only with specific input types, primarily text-
based.
• It uses a regular expression to restrict the allowed input format.
• Validation using pattern happens on form submission.
• Combine it with title to provide a helpful tooltip for users (e.g., title="Only letters
allowed").
Exam Tip:
If you want to validate input format (e.g., 6-digit PIN, phone number, custom code),
use type="text" with the pattern attribute.
Example:
✅ Question 4
Emily has to create a form with an input field having 'Emily' as the default value and
also give the user a hint as 'Enter Your Name Here' when no text is entered in the
field.
Options:
a)
<label for="name">userName:</label><input type="text" id="name" value="Enter Your
Name Here" placeholder="Emily">
b)
<label for="name">userName:</label> <input type="text" id="name" value="Emily"
placeholder="Enter Your Name Here">
c)
<label for="name">userName:</label> <input type="text" id="name" value="Emily"
placeholder="Enter Your Name Here">Enter Your Name Here
d)
<label for="name">userName:</label><input type="text" id="name" value="Enter Your
Name Here" placeholder="Enter Your Name Here">Emily
Correct Answer: b)
<label for="name">userName:</label> <input type="text" id="name"
value="Emily" placeholder="Enter Your Name Here">
Explanation:
HTML input fields support two commonly used attributes to improve usability:
• value="..." – This sets the default value (pre-filled text in the field when the form
loads).
• placeholder="..." – This shows hint text when the input is empty and disappears
as soon as the user types something.
Option a:
Incorrect – value="Enter Your Name Here" sets the default value to the hint, and the
placeholder shows 'Emily', which is the reverse of what Emily wants.
Option b:
Correct – value="Emily" sets 'Emily' as the pre-filled value. placeholder="Enter Your
Name Here" shows the hint when the field is empty. Matches the requirement exactly.
Option c:
Incorrect – The extra text outside the input (Enter Your Name Here) will appear next
to the input field, not as a placeholder or default value.
Option d:
Incorrect – Again, the value and placeholder are set incorrectly, and extra static text
Emily is placed outside the input field.
Exam Tip:
Always differentiate between value (actual data) and placeholder (instructional hint).
For form usability, it's best to use both to guide users clearly.
✅ Question 5
Which of the following statements is true about the alt attribute (commonly called the
"alt tag") in HTML?
Statements:
Options:
a) only 1
b) only 2
c) both 1 and 2
d) neither 1 or 2
Explanation:
The alt attribute is used inside the <img> tag to provide alternative text for an image.
1. Accessibility: Screen readers read the alt text aloud for visually impaired users.
2. Fallback display: If the image cannot be displayed (e.g., file missing, broken
link, or slow network), the browser shows the alt text instead.
It does NOT display when the image is available and renders properly.
• Statement 1 – Incorrect:
The alt text is not shown if the image loads successfully.
• Statement 2 – Correct:
The alt text is shown when the image is unavailable or fails to load.
Example:
Exam Tip:
• Use alt text to describe the image meaningfully, not just "image" or "photo".
• If the image is purely decorative, alt="" is preferred for accessibility.
✅ Question 6
Julie has created the following HTML form. In this form, the user is currently able to
select multiple choices through the radio buttons.
<form>
User Name: <input type="text" required/>
Password: <input type="password" required/>
Male <input type="radio" value="Male" />
Female <input type="radio" value="Female" />
Others <input type="radio" value="Others" />
</form>
Options:
a) Usage of id attribute with same value in all the radio type inputs
b) Usage of name attribute with same value in all the radio type inputs
c) Usage of for attribute with same value in all the radio type inputs
d) Usage of value attribute having same name in all the radio type inputs
Correct Answer: b) Usage of name attribute with same value in all the radio
type inputs
Explanation:
Radio buttons in HTML are meant to allow only one selection from a group of related
options. However, this only works if all radio buttons in the group share the same
name attribute.
• Julie has created three <input type="radio"> elements, but none of them has
a name attribute, or they all have different names by default.
• Without a shared name, the browser treats each radio button as part of a
separate group — hence, multiple buttons can be selected simultaneously.
To fix it, assign the same name to all radio buttons like so:
Option-by-Option Analysis:
Option a – id attribute:
id must be unique per element — using the same id causes invalid HTML and won’t
group the buttons.
• Radio buttons with the same name are treated as a group — only one option is
selectable at a time.
• value determines what is submitted, not grouping behavior.
• id should be unique; for is used for accessibility with labels.
Exam Tip:
Always use the same name attribute for a group of radio buttons to enforce mutually
exclusive selection — a common form-related HTML interview question.
✅ Question 7
What will be the output of the following HTML code when rendered in a browser?
<html>
<body>
welcome>user
</body>
</html>
Options:
a) welcome>user
b) welcome user
c) welcome
d) user
(Note: Although in actual code it’s written as welcome>user, the browser will render it
exactly as written, displaying welcome>user, which matches option a.)
Explanation:
<html>
<body>
welcome>user
</body>
</html>
• This line contains plain text: welcome>user
• The greater-than sign (>) is not part of any HTML tag here — it's simply treated
as text content.
• In HTML, unless special characters like <, >, &, etc., are used as part of actual
tag syntax, they are treated like normal characters when outside tags.
welcome>user
a) welcome>user
Correct – this is what the browser will show.
b) welcome user
Incorrect – the > is not removed or replaced with a space.
c) welcome
Incorrect – the entire string is shown, not truncated.
d) user
Incorrect – no logic in the code strips out the first word.
• Characters like > and < are special in HTML only when used as part of tag
syntax.
• Text between <body>...</body> that does not match a valid HTML element or
tag is displayed as-is.
• Browsers are generally forgiving with minor syntax errors and treat
unrecognized tags or characters as plain text.
Exam Tip:
If it looks like text and isn't a valid HTML element, the browser will likely just render it
as plain text. Don’t confuse symbols like > with tags unless they are part of <tag>
syntax.
✅ Question 8
Elon is developing a web application to display cricket scores of live matches. He
wants the web page to auto-refresh every 45 seconds.
Which of the following attributes of the <meta> tag will help him to achieve this
requirement?
<html>
<head>
<meta ________________ />
</head>
<body>
...
</body>
</html>
Options:
Explanation:
The <meta> tag can be used to send additional information (metadata) to the browser.
To make a page auto-refresh, we use the http-equiv="refresh" attribute.
This makes the page automatically reload every 45 seconds — perfect for live data like
cricket scores!
Option-by-Option Analysis:
Exam Tip:
To force a page to refresh periodically (like for news updates, live scores, etc.), use the
http-equiv="refresh" meta tag.
You can even redirect to a different URL like this:
✅ Question 9
<table border="2">
<tr>
<td <!--1--> >sun</td>
<td>rises</td>
<td>in the</td>
</tr>
<tr>
Options:
Explanation:
1. <!--1-->: The first <td> merges with the next cell in the same row
So it must be colspan="2"
2. <!--2-->: This <td> cell is placed directly under the one from above, and must
stretch across two columns
So it must be rowspan="2"
3. <!--3-->: This cell spans downward over two rows
So it must be rowspan="2"
4. <!--4-->: This cell spans across two columns
So it must be colspan="2"
Exam Tip:
If a table is not rendering as expected, check if colspan and rowspan are correctly used.
Matching column and row counts across rows is crucial for well-formed tables.
✅ Question 10
Which of the below elements is used to add multiple audio/video clips in HTML?
Options:
a) audio
b) video
c) link
d) source
Explanation:
The <source> element in HTML is used within <audio> or <video> tags to provide
multiple file formats of the same media. This ensures browser compatibility — since
not all browsers support all media types.
The browser chooses the first supported file format and plays it.
Example:
<video controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Option-by-Option Analysis:
a) audio
Incorrect – used as a container for audio playback, not for specifying multiple files.
b) video
Incorrect – also a container for video playback.
c) link
Incorrect – used for linking external CSS or favicon files, not media.
d) source
Correct – used inside audio/video to list different formats of the same clip.
Exam Tip:
Always include at least two file formats (e.g., .mp4, .ogg, .webm) using <source> to
ensure broad media support across different browsers.
✅ Question 11
Whenever he tries to test it, he faces the issue of having to satisfy all the validations
provided.
Options:
Correct Answers:
Explanation:
HTML5 introduced client-side validation for form controls using attributes like
required, pattern, minlength, maxlength, etc.
If Charlie is testing the form and doesn’t want to trigger validations every time, he can
temporarily disable validation using two key attributes:
This is useful when a form has multiple submit buttons, and one is meant to skip
validation.
Disables all HTML5 validations for that form, no matter how many inputs or submit
buttons it contains.
Ideal for disabling validations during testing or for dynamic validation via JavaScript.
This does not disable validations. It only affects where the form submits to.
The form will still perform validation before submitting (to the same page, if no action is
provided).
Invalid – formnovalidate is an attribute for submit buttons only, not input fields.
So this would have no effect.
Exam Tip:
To bypass client-side validation in HTML for testing purposes or optional submissions,
prefer:
• novalidate (form-level)
• formnovalidate (submit-button-level)
✅ Question 12
Zovian Space™ & Wisdor Tech are privately funded organizations that creates cutting
edge space suits.
Their suits can withstand a temperature between -200°F to 500°F.
Fill in the blanks with HTML code snippets to obtain the above output:
<p id="demo">
Zovian Space<!-- 1 --> <!-- 2 --> Wisdor Tech are privately funded organizations that
creates cutting edge
<!-- 3 --><br/>
Their suits can withstand a temperature between -200<!-- 4 --> to 500<!-- 5 -->F.
</p>
Options:
a)
1: &tm; 2: &hand; 3: <em>space suits</em> 4 and 5: <small>o</small>
b)
1: ™ 2: & 3: <mark>space suits</mark> 4 and 5: <sup>o</sup>
c)
1: <sup>TM</sup> 2: /&; 3: <ins>space suits</ins> 4 and 5: <sup>O</SUP>
d)
1: ™ 2: &; 3: <mark>space suits</mark> 4 and 5: <sub>o</sub>
Correct Answer: b)
Let’s match each blank to the correct code that will produce the desired output:
1 →™ symbol:
• HTML allows using the character ™ directly, or you can use the entity ™ or
™.
• In the options, Option b and d use ™ directly — which works in most browsers.
Correct value: ™
<p id="demo">
Zovian Space™ & Wisdor Tech are privately funded organizations that creates cutting
edge
<mark>space suits</mark><br/>
Their suits can withstand a temperature between -200<sup>o</sup> to
500<sup>o</sup>F.
</p>
• ™ and & can be rendered directly or via their HTML entities (™, &)
• <mark> highlights text, <em> italicizes, <ins> underlines
• Use <sup> for superscript (like degrees °), and <sub> for subscript
Exam Tip:
✅ Question 13
Options:
a) Version of HTML
b) Features of HTML
c) Specifications of HTML
d) All of the above
Correct Answer: a) Version of HTML
Explanation:
<!DOCTYPE html>
It does not provide actual feature or specification details — it only helps the
browser interpret the rest of the code based on a known version.
Option-by-Option Analysis:
a) Version of HTML
Correct – This is the primary purpose of <!DOCTYPE>.
b) Features of HTML
Incorrect – It doesn't list or describe features of the HTML version.
c) Specifications of HTML
Incorrect – It doesn’t define or include HTML specifications.
• The <!DOCTYPE> declaration must be the very first thing in the HTML
document.
• It’s not an HTML tag, but a declaration.
• It tells the browser to use standards-compliant mode instead of quirks mode.
• In HTML5, it is written as <!DOCTYPE html> (case-insensitive).
Exam Tip:
Always include <!DOCTYPE html> at the top of your HTML documents to ensure the
browser renders in standards mode, especially when targeting HTML5.
✅ Question 14
Options:
Explanation:
Option-by-Option Analysis:
a) <img src="tea.jpeg"> A tea plantation on hills of Munnar </img>
Incorrect –
Example:
Exam Tip:
What will happen when the user clicks on the "Submit" button?
Options:
Explanation:
Hence, the user will navigate to Contact.html, not submit the form to About.html.
Option-by-Option Analysis:
a) About.html
Incorrect – No form submission happens because the button is not of type "submit".
b) Contact.html
Correct – Because the <input type="button"> is wrapped inside <a>, clicking it
triggers link navigation.
c) Browser dependent
Incorrect – Behavior is consistent across browsers.
d) No navigation
Incorrect – Clicking the button will navigate, because of the anchor link.
Exam Tip:
If you want to submit a form when the user clicks a button, use:
If you want just a clickable button without submitting, use type="button", and attach
JavaScript or link it appropriately.
✅ Question 16
John, a web developer, wants to group all navigation links in his web page.
Which of the below semantic tags can be used to meet John’s requirement?
Options:
a) <nav>
b) <navbar>
c) <header>
d) <a>
Explanation:
Semantic HTML introduces meaning to the structure of a web page, making it easier
for browsers, search engines, and developers to understand the role of different parts.
• Home
• About Us
• Services
• Contact
• FAQs
It helps screen readers and search engines identify important navigation areas
clearly.
Example:
<nav>
<a href="home.html">Home</a>
<a href="services.html">Services</a>
<a href="contact.html">Contact</a>
</nav>
Option-by-Option Analysis:
a) <nav>
Correct – specifically designed for navigation links grouping.
b) <navbar>
Incorrect –
There is no <navbar> element in HTML5. Developers may use the class name "navbar"
in CSS frameworks like Bootstrap, but it's not an official HTML tag.
c) <header>
Incorrect –
<header> defines introductory content, headings, logos, etc., not specifically for
navigation links.
d) <a>
Incorrect –
<a> defines a single hyperlink, not a container to group multiple links semantically.
Exam Tip:
When asked about semantic containers for navigation menus, always choose <nav>.
Semantic tags improve accessibility, SEO, and overall code clarity.
✅ Question 17
John wants to write the HTML code that gives the following output:
Which of the following HTML code snippets will produce the above output?
Options:
a)
b)
c)
d)
Correct Answer: d)
Explanation:
Option-by-Option Analysis:
a)
Incorrect –
Uses <mark>, which highlights text unnecessarily. Output will not match.
b)
Incorrect –
Closing tags are mismatched (</sub></sub>), leading to rendering issues.
c)
Incorrect –
There is an extra closing </sub>, making HTML invalid.
d)
Correct –
All tags are valid and correctly structured.
Only "human-to-human / computer interaction" uses <sub> formatting properly.
Exam Tip:
Always match opening and closing tags carefully when handling nested elements like
<abbr>, <sub>, <mark>, etc.
Any mismatch can cause browser rendering issues and unexpected formatting.
✅ Question 18
What do you expect the below HTML code to display in the browser?
<article>
Its all about Infy!!
</article>
<footer>
copyright
</footer>
<header>
Keep your heads always High!!
</header>
<section>
dont dare alter my section!!
</section>
Options:
a) Keep your heads always High!! dont dare alter my section!! Its all about Infy!!
copyright
b) Its all about Infy!! copyright Keep your heads always High!! dont dare alter my
section!!
c) dont dare alter my section!! Keep your heads always High!! copyright Its all about
Infy!!
d) Its all about Infy!! Keep your heads always High!! copyright dont dare alter my
section!!
Correct Answer: b) Its all about Infy!! copyright Keep your heads always High!!
dont dare alter my section!!
Explanation:
• HTML by default displays content in the order in which the elements appear in
the code (unless CSS is applied to change layout).
• Semantic tags like <header>, <footer>, <section>, <article> simply define
meaningful blocks but do not affect the order of content rendering.
• Thus, the browser renders the elements sequentially as:
1. Article: "Its all about Infy!!"
2. Footer: "copyright"
3. Header: "Keep your heads always High!!"
4. Section: "dont dare alter my section!!"
Its all about Infy!! copyright Keep your heads always High!! dont dare alter my section!!
Option-by-Option Analysis:
a)
Incorrect – Changes order (header and section appear first).
b)
Correct – Matches the exact top-to-bottom flow of the code.
c)
Incorrect – Section is coming first here, which is wrong.
d)
Incorrect – Header comes before footer in this option, which is incorrect according
to the original code.
• HTML renders elements in the order they appear in code unless modified by
CSS.
• Tags like <header>, <section>, <article>, and <footer> are semantic tags
— they define meaning but not rendering order.
• These tags are very useful for SEO, accessibility, and page structure but not for
visual arrangement unless styled.
Exam Tip:
✅ Question 19
Without entering any value, the user is able to submit the form even though the
required attribute is present.
Options:
The issue is that the first option ("--Select--") does not have an empty value, so even
when it is selected, the browser treats it as a valid selection.
• The selected option must have a non-empty value for the form to be
considered valid.
• If the default option ("--Select--") has some text but no value="", the form
mistakenly thinks something is selected and allows submission.
<option value="">--Select--</option>
Now, if the user doesn't actively pick a car, the browser sees an empty value and blocks
form submission.
Option-by-Option Analysis:
• Always provide value="" for placeholder options like "--Select--" when using
required.
• The first default option should act as a prompt, not a valid selection.
• <select> validation checks if a non-empty value has been selected.
Corrected Code:
<option value="">--Select--</option>
Exam Tip:
When using <select required>, make sure the default visible option has value=""
so the browser forces the user to make a selection before submitting.
✅ Question 20
Chris has a video on his webpage and he wants to display an image until the video
starts to play.
Which of the following will help him achieve this?
Options:
a)
b)
<video controls>
<source src="OORelationships.mp4" type="video/mp4" poster="class_diagram.png">
</video>
c)
d)
<video controls>
<source src="OORelationships.mp4" type="video/mp4" poster="class_diagram.png">
<img src="class_diagram.png" alt="Class Diagram is Invalid!!!">
</source>
</video>
Correct Answer: a)
Explanation:
In HTML5, the <video> element is used to embed video content into a webpage.
Option-by-Option Analysis:
c) <video img="...">
Incorrect – img is not a valid attribute for <video>.
d) <video><source> + <img>
Incorrect – Placing <img> inside <source> and <video> is invalid HTML structure.
Correct pattern:
Exam Tip:
✅ Question 21
What will be the valid range of values that can be entered for the input field
named "weight"?
<form action="#">
Weight:
<input type="number" id="" max="71" min="20" step="2.5">
<button type="submit">Submit</button>
</form>
Options:
a) 20 to 71
b) 20 to 70
c) 20 to 68.5
d) All real numbers
Correct Answer: a) 20 to 71
Explanation:
Starting at 20:
• 20
• 22.5
• 25
• 27.5
• 30
• 32.5
• 35
• 37.5
• 40
• 42.5
• 45
• 47.5
• 50
• 52.5
• 55
• 57.5
• 60
• 62.5
• 65
• 67.5
• 70
Now if you add 2.5 to 70, you get 72.5, which exceeds the max value (71).
Hence, 71 itself must be entered directly (if allowed manually), or browser may
restrict it based on step size mismatch.
a) 20 to 71
Correct – minimum 20, maximum 71.
b) 20 to 70
Incorrect – 71 is allowed as per the max attribute.
c) 20 to 68.5
Incorrect – 68.5 is a wrong limit based on 2.5 steps; also max is 71.
Example:
Valid values would be: 10, 15, 20, 25, 30, 35, 40, 45, 50.
Exam Tip: