MCQs
Working
with Links in HTML
1. What is the purpose of
the href attribute in an <a> tag?
o A) To specify the style
of the link
o B) To specify the URL of
the linked document
o C) To define the color
of the link
o D) To provide a tooltip
for the link
Answer: B) To specify the URL of the linked document
2. Which attribute is used
to open a link in a new tab or window?
o A) title
o B) target
o C) rel
o D) href
Answer: B) target
3. What value should be
used with the target attribute to ensure a link opens in a new tab?
o A) _parent
o B) _top
o C) _blank
o D) _self
Answer: C) _blank
4. Which attribute can be
used to provide additional information about a link, typically displayed as a
tooltip?
o A) href
o B) rel
o C) title
o D) target
Answer: C) title
5. What is the correct way
to create a link to an email address?
o A) <a
href="mailto:example@example.com">Email Us</a>
o B) <a
href="http://mailto:example@example.com">Email Us</a>
o C) <a
href="email:example@example.com">Email Us</a>
o D) <a
href="example@example.com">Email Us</a>
Answer: A) <a href="mailto:example@example.com">Email
Us</a>
6. How can you make a link
to a specific section of the same page?
o A) Use
href="#sectionID"
o B) Use
href="sectionID"
o C) Use
href="http://#sectionID"
o D) Use
href="section.html#sectionID"
Answer: A) Use href="#sectionID"
7. What attribute should be
used to prevent the new page from having access to the window.opener property
when using target="_blank"?
o A)
rel="noreferrer"
o B)
rel="noopener"
o C)
title="noopener"
o D)
target="noopener"
Answer: B) rel="noopener"
8. Which attribute is used
to specify the relationship between the current document and the linked
document?
o A) target
o B) title
o C) href
o D) rel
Answer: D) rel
9. What does the tel:
scheme in a link do?
o A) Opens a map
application with a specific address
o B) Initiates a phone
call on devices that support it
o C) Opens a text message
interface
o D) Sends an email to the
provided address
Answer: B) Initiates a phone call on devices that support it
10.
What is the effect of using rel="noreferrer" with a
link?
o A) It disables the
referrer header from being sent
o B) It opens the link in
the same tab
o C) It adds a tooltip to
the link
o D) It ensures the link
opens in a new tab
Answer: A) It disables the referrer header from being sent
11.
Which HTML tag is used to create a hyperlink?
o A) <link>
o B) <a>
o C) <hyperlink>
o D) <url>
Answer: B) <a>
12.
What is the default behavior of a hyperlink when the target
attribute is not specified?
o A) It opens in a new
window
o B) It opens in a new tab
o C) It opens in the same
window or tab
o D) It opens in a popup
Answer: C) It opens in the same window or tab
13.
How do you link to an external stylesheet in an HTML document?
o A) <link
href="styles.css" rel="stylesheet">
o B) <a
href="styles.css" rel="stylesheet">
o C) <style
src="styles.css"></style>
o D) <script
src="styles.css"></script>
Answer: A) <link href="styles.css"
rel="stylesheet">
14.
Which attribute is used to specify the relationship between the
current document and the linked document?
o A) href
o B) rel
o C) title
o D) target
Answer: B) rel
15.
What value should you use for the rel attribute to specify that a
link should not pass a referrer header to the linked document?
o A) noopener
o B) noreferrer
o C) nofollow
o D) noopener noreferrer
Answer: B) noreferrer
16.
How do you create a link to a file located in the same directory
as the HTML file?
o A) <a
href="file.txt">Download File</a>
o B) <a
href="./file.txt">Download File</a>
o C) <a
href="/file.txt">Download File</a>
o D) <a
href="file.html">Download File</a>
Answer: A) <a href="file.txt">Download
File</a>
17.
Which HTML attribute can be used to provide a brief description of
the link’s target?
o A) alt
o B) title
o C) description
o D) tooltip
Answer: B) title
18.
How do you create a link that opens in the same window but with a
different document?
o A) <a
href="page.html" target="_blank">Go to Page</a>
o B) <a
href="page.html" target="_self">Go to Page</a>
o C) <a
href="page.html" target="_parent">Go to Page</a>
o D) <a
href="page.html" target="_top">Go to Page</a>
Answer: B) <a href="page.html"
target="_self">Go to Page</a>
19.
What happens if the target="_blank" attribute is used
without rel="noopener noreferrer"?
o A) The link will open in
the same tab
o B) The new page may have
access to the window.opener property, which can be a security risk
o C) The link will open in
a popup window
o D) The link will not
open
Answer: B) The new page may have access to the window.opener
property, which can be a security risk
20.
Which of the following is NOT a valid value for the target
attribute?
o A) _blank
o B) _self
o C) _parent
o D) _new
Answer: D) _new
21.
What is the purpose of the rel="nofollow" attribute in a
link?
o A) To prevent the link
from being indexed by search engines
o B) To make the link open
in a new window
o C) To provide additional
information about the link
o D) To apply custom
styles to the link
Answer: A) To prevent the link from being indexed by search engines
22.
Which attribute is used to link to a specific fragment within the
same document?
o A) href
o B) id
o C) class
o D) name
Answer: A) href
23.
How can you create a link that opens a document in the same frame
or window, replacing the current document?
o A) <a
href="document.html" target="_blank">Open
Document</a>
o B) <a
href="document.html" target="_self">Open
Document</a>
o C) <a
href="document.html" target="_top">Open
Document</a>
o D) <a
href="document.html" target="_parent">Open
Document</a>
Answer: B) <a href="document.html"
target="_self">Open Document</a>
24.
What value should you use with the target attribute to ensure the
link opens in the top-most browsing context?
o A) _self
o B) _top
o C) _parent
o D) _blank
Answer: B) _top
25.
Which of the following is a correct way to link to a section on an
external page?
o A) <a
href="externalpage.html#sectionID">Go to Section</a>
o B) <a
href="externalpage.html" id="sectionID">Go to Section</a>
o C) <a
href="#externalpage.html#sectionID">Go to Section</a>
o D) <a
href="externalpage.html#sectionID" target="_top">Go to
Section</a>
Answer: A) <a href="externalpage.html#sectionID">Go
to Section</a>
26.
Which HTML element is used to create a list of links for
navigation?
o A) <ul>
o B) <ol>
o C) <nav>
o D) <div>
Answer: C) <nav>
27.
How do you ensure that a link to an external site includes a title
attribute for additional context?
o A) <a
href="https://www.example.com" title="Visit Example
Website">Example</a>
o B) <a
href="https://www.example.com" tooltip="Visit Example
Website">Example</a>
o C) <a
href="https://www.example.com" alt="Visit Example
Website">Example</a>
o D) <a
href="https://www.example.com" description="Visit Example
Website">Example</a>
Answer: A) <a href="https://www.example.com"
title="Visit Example Website">Example</a>
28.
What does the href attribute in a link do if it is left empty?
o A) The link will open
the current page in a new tab
o B) The link will not
function
o C) The link will
navigate to the root of the domain
o D) The link will display
an error message
Answer: B) The link will not function
29.
How can you link to an anchor within the same document?
o A) <a
href="#sectionID">Go to Section</a>
o B) <a
href="sectionID">Go to Section</a>
o C) <a
href="/#sectionID">Go to Section</a>
o D) <a
href="section.html#sectionID">Go to Section</a>
Answer: A) <a href="#sectionID">Go to
Section</a>
30.
Which attribute would you use to include a link that opens an
email client with a pre-filled subject line?
o A) href="mailto:someone@example.com?subject=Hello"
o B)
href="mailto:someone@example.com&subject=Hello"
o C)
href="mailto:someone@example.com?body=Hello"
o D)
href="mailto:someone@example.com#subject=Hello"
Answer: A) href="mailto:someone@example.com?subject=Hello"
31.
Which attribute is used to specify a link that should not be
indexed by search engines?
o A)
rel="nofollow"
o B)
target="_blank"
o C)
title="noindex"
o D)
href="nofollow"
Answer: A) rel="nofollow"
32.
How can you create a link that opens a document in the parent
frame?
o A) <a
href="document.html" target="_self">Open
Document</a>
o B) <a
href="document.html" target="_parent">Open
Document</a>
o C) <a
href="document.html" target="_top">Open
Document</a>
o D) <a
href="document.html" target="_blank">Open
Document</a>
Answer: B) <a href="document.html"
target="_parent">Open Document</a>
33.
Which value for the target attribute will open a link in the most
top-level browsing context (full window)?
o A) _self
o B) _blank
o C) _top
o D) _parent
Answer: C) _top
34.
What is the effect of using rel="noopener noreferrer" in
a link with target="_blank"?
o A) It opens the link in
a new tab
o B) It prevents the new
page from having access to the window.opener property and disables the referrer
header
o C) It adds a tooltip to
the link
o D) It makes the link
open in the same tab
Answer: B) It prevents the new page from having access to the
window.opener property and disables the referrer header
35.
Which of the following is NOT a valid HTML link type?
o A) <a
href="http://example.com">
o B) <a
href="mailto:example@example.com">
o C) <a
href="tel:+1234567890">
o D) <a
href="file://localpath">
Answer: D) <a href="file://localpath">
36.
What is the purpose of the href attribute in a <link> tag?
o A) To specify the URL of
the linked document
o B) To specify the
relationship between the current document and the linked document
o C) To specify the type
of link, such as a stylesheet or favicon
o D) To specify a unique
identifier for the link
Answer: C) To specify the type of link, such as a stylesheet or
favicon
37.
How would you create a link that leads to a file within a
subfolder of the current directory?
o A) <a
href="subfolder/file.txt">Open File</a>
o B) <a
href="file/subfolder/file.txt">Open File</a>
o C) <a
href="./subfolder/file.txt">Open File</a>
o D) <a
href="/subfolder/file.txt">Open File</a>
Answer: A) <a href="subfolder/file.txt">Open
File</a>
38.
Which of the following is the correct syntax to link to an
external JavaScript file?
o A) <a
href="script.js">JavaScript File</a>
o B) <link
href="script.js" rel="script">
o C) <script
src="script.js"></script>
o D) <a
src="script.js">JavaScript File</a>
Answer: C) <script src="script.js"></script>
39.
Which attribute is used to set a default target for all links
within a <form> element?
o A) formtarget
o B) target
o C) formaction
o D) formmethod
Answer: B) target
40.
How can you ensure that a link to a PDF file is opened in the
browser's built-in PDF viewer?
o A) <a
href="file.pdf" download>Open PDF</a>
o B) <a
href="file.pdf" target="_blank">Open PDF</a>
o C) <a
href="file.pdf" rel="noopener">Open PDF</a>
o D) <a
href="file.pdf" type="application/pdf">Open
PDF</a>
Answer: B) <a href="file.pdf"
target="_blank">Open PDF</a>
41.
What will be the result of this HTML code: <a
href="#section1">Go to Section 1</a> if there is no element
with id="section1"?
o A) The link will open a
new page
o B) The link will
navigate to the top of the page
o C) The link will do
nothing
o D) The browser will
display an error message
Answer: C) The link will do nothing
42.
Which attribute is used to specify the type of content being linked
in an <a> tag?
o A) type
o B) media
o C) href
o D) rel
Answer: D) rel
43.
Which of the following attributes can be used to give a link a
tooltip that appears when the user hovers over the link?
o A) tooltip
o B) alt
o C) title
o D) desc
Answer: C) title
44.
What is the purpose of using rel="noopener" in
conjunction with target="_blank"?
o A) To add a tooltip to
the link
o B) To prevent the new
page from accessing the original page’s window object
o C) To specify that the
link should open in the same window
o D) To change the color
of the link
Answer: B) To prevent the new page from accessing the original
page’s window object
45.
How can you ensure that a link to a website opens in a new window
and does not affect the referrer information?
o A) <a
href="http://example.com" target="_blank"
rel="noopener noreferrer">Visit Example</a>
o B) <a
href="http://example.com" target="_blank"
rel="noreferrer">Visit Example</a>
o C) <a
href="http://example.com" target="_new"
rel="noopener">Visit Example</a>
o D) <a
href="http://example.com" target="_blank"
rel="noindex">Visit Example</a>
Answer: A) <a href="http://example.com"
target="_blank" rel="noopener noreferrer">Visit
Example</a>
46.
Which HTML tag is typically used to create links to external
resources, such as stylesheets or icons, rather than navigation?
o A) <link>
o B) <a>
o C) <nav>
o D) <script>
Answer: A) <link>
47.
What does the href attribute in a <link> element define?
o A) The URL of the
resource being linked
o B) The type of content
the link points to
o C) The relationship of
the linked document
o D) The identifier of the
linked document
Answer: A) The URL of the resource being linked
48.
What will be the outcome of this HTML code: <a
href="https://example.com"
rel="noopener">Example</a>?
o A) The link will open in
a new tab without passing the referrer information
o B) The link will open in
the same tab
o C) The link will open a
popup window
o D) The link will not be
functional
Answer: A) The link will open in a new tab without passing the
referrer information
49.
How can you link to an HTML document that is located in a parent
directory of the current document?
o A) <a
href="../document.html">Parent Directory Document</a>
o B) <a
href="/document.html">Parent Directory Document</a>
o C) <a
href="document.html">Parent Directory Document</a>
o D) <a
href="./document.html">Parent Directory Document</a>
Answer: A) <a href="../document.html">Parent
Directory Document</a>
50.
What effect does the download attribute have when used with an
<a> tag?
o A) It opens the linked
file in a new window
o B) It triggers a
download of the file rather than navigating to it
o C) It ensures the file
opens in the same tab
o D) It adds a tooltip to
the link
Answer: B) It triggers a download of the file rather than navigating
to it
***********************************************
