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