Which attribute is commonly used to create internal anchors for linking within a page?

Learn web design with our comprehensive test guide. Improve your skills with flashcards and multiple choice questions. Each question includes hints and explanations. Get ready to ace your exam!

Multiple Choice

Which attribute is commonly used to create internal anchors for linking within a page?

Explanation:
Internal anchors are created by using the id attribute on the target element and linking to that id with a fragment in the URL, like href="#section-id". When you click the link, the browser scrolls to the element with that id. The id must be unique in the page so the browser lands on the correct element. The other attributes don’t serve this purpose: class groups elements for styling or scripting and can be shared by many elements, so it can’t serve as a single anchor target; the title attribute just provides a tooltip; and the style attribute applies inline CSS. In modern HTML, using a unique id for the target and a matching href with a hash is the standard way to create internal anchors.

Internal anchors are created by using the id attribute on the target element and linking to that id with a fragment in the URL, like href="#section-id". When you click the link, the browser scrolls to the element with that id. The id must be unique in the page so the browser lands on the correct element. The other attributes don’t serve this purpose: class groups elements for styling or scripting and can be shared by many elements, so it can’t serve as a single anchor target; the title attribute just provides a tooltip; and the style attribute applies inline CSS. In modern HTML, using a unique id for the target and a matching href with a hash is the standard way to create internal anchors.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy