Link targets MCQs Quiz | Class 10

This quiz is designed for **Class X** students, covering **Computer Applications (Code 165)**, specifically from **Unit 2: HTML**. The topic is **Link targets MCQs Quiz | Class 10**, focusing on the `target` attribute and the concept of opening links in new tabs or windows. Test your knowledge, submit your answers to see your score, and download a detailed answer PDF for revision.

Understanding Link Targets in HTML

In HTML, hyperlinks are created using the `` tag. These links allow users to navigate between different web pages or sections within a page. A crucial aspect of controlling how a linked document opens is the `target` attribute. This attribute specifies where the linked document will open when the user clicks on the link.

The `target` Attribute

The `target` attribute is used within the `` (anchor) tag to define the browsing context (a window, a tab, or an iframe) in which the linked document should open. It gives you control over the user’s navigation experience.

Example: <a href="https://www.example.com" target="_blank">Visit Example</a>

Common `target` Values

There are several predefined values for the `target` attribute, each with a specific behavior:

  • `_self` (Default): This is the default behavior if no `target` attribute is specified. It opens the linked document in the same browsing context (the same window or tab) that the link was clicked. This is generally preferred for internal links to keep users on your site.
  • `_blank` (New Window/Tab): This value opens the linked document in a new, unnamed browsing context (typically a new browser window or tab). It is commonly used for external links so that the user’s current page remains open.
  • `_parent`: If the link is inside an iframe, `_parent` opens the linked document in the parent browsing context of the current one. If there is no parent (i.e., the link is not in an iframe), it behaves like `_self`.
  • `_top`: This value opens the linked document in the topmost browsing context (the full browser window), breaking out of any framesets. If there are no frames, it behaves like `_self`.
  • `framename`: You can also specify a custom name (e.g., `target=”myiframe”`). This will open the linked document in the iframe or window with that specific name. If a browsing context with that name does not exist, a new one will be created.

When to Use `_blank` (Open in New Tab/Window)

The `target=”_blank”` attribute is powerful but should be used judiciously.

Scenario Reason for `_blank`
External Websites Keeps users on your current site while allowing them to explore external resources.
Downloadable Files Prompts download without navigating away from the current page.
Large Media/PDFs Opens content in a new view, preserving the user’s position on the main site.
Special Features (e.g., Maps) Dedicated views for interactive elements.

Security and Best Practices with `_blank`

When using `target=”_blank”`, it’s crucial to include `rel=”noopener noreferrer”` for security and performance reasons:

  • `noopener` (Security): Prevents the new page from accessing the `window.opener` property of the opening page, which could be exploited for “tabnabbing” phishing attacks.
  • `noreferrer` (Security/Privacy): Prevents the browser from sending the `Referer` header to the new page. This enhances privacy by not revealing the source of the click.

Correct Usage: <a href="external.html" target="_blank" rel="noopener noreferrer">External Link</a>

`target` Attribute with Forms

The `target` attribute can also be used with the HTML `

` tag. When used with a form, it specifies where the response received after submitting the form should be displayed. The values work identically to those for the `` tag.

Example: <form action="/submit" method="post" target="_blank">...</form>

Quick Revision

  • `target` attribute controls where a linked document opens.
  • `_self` is the default (same window/tab).
  • `_blank` opens in a new window/tab.
  • `_parent` opens in the parent frame.
  • `_top` opens in the full browser window.
  • Always use `rel=”noopener noreferrer”` with `target=”_blank”` for security.
  • The `target` attribute can also be used with `` tags.

Practice Questions

Test your understanding further with these questions:

  1. Which HTML tag is primarily associated with the `target` attribute for navigation?
  2. What is the main benefit of using `target=”_blank”` for external links?
  3. If an `` tag has no `target` attribute, what is the default behavior?
  4. Explain the security risk associated with `target=”_blank”` if `rel=”noopener”` is not used.
  5. Can you specify a custom named frame as a `target`? If so, what happens if that frame doesn’t exist?

Author

  • CBSE Quiz Editorial Team

    Content created and reviewed by the CBSE Quiz Editorial Team based on the latest NCERT textbooks and CBSE syllabus. Our goal is to help students practice concepts clearly, confidently, and exam-ready through well-structured MCQs and revision content.