Câu hỏi phỏng vấn HTML
Câu hỏi

Where and why is the rel="noopener" attribute used?

Câu trả lời

The rel="noopener" attribute is used in HTML within the <a>, <area>, and <form> elements. It is specifically applied to hyperlinks (defined by the <a> tag) that open a target URL in a new browsing context, such as a new tab or window, which is typically specified using the target="_blank" attribute.

Purpose of rel="noopener"

The primary purpose of the rel="noopener" attribute is to enhance security by preventing the newly opened page from accessing the window.opener property of the page that opened it. This property could otherwise allow the new page to control the original page, leading to potential security risks such as phishing attacks. By setting window.opener to null, the rel="noopener" attribute effectively severs any connection between the two pages, ensuring that the originating document remains secure from potential malicious tampering by the opened page[1][2][3][6].

Usage in HTML

Here is how the rel="noopener" attribute is typically used in an HTML anchor tag:

html Copy
<a href="https://example.com" target="_blank" rel="noopener">Visit Example</a>

In this example, clicking the link opens "https://example.com" in a new tab, and the rel="noopener" attribute prevents the new tab from accessing the window.opener property of the original page.

Impact on SEO and Web Practices

From an SEO perspective,...

middle

middle

Gợi ý câu hỏi phỏng vấn

middle

What's new in HTML 5?

junior

What is Character Encoding?

middle

What is an optional tag?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào