HTM-02300 | What is an element and a href attribute?
What is an <a> element?
- An
<a>
element is considered an anchor element. - An anchor is a piece of text which marks the beginning and/or the end of a hypertext link.
- The
<a>
tag defines a hyperlink, which is used to link from one page to another. - It creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.
- It goes with the
href
attribute, which indicates the link’s destination.
Click here to view an <a>
and href
example.
What is an href attribute?
- (Hypertext REFerence) The HTML code used to create a link to another page.
- The
href
is an attribute of the anchor tag, which is also used to identify sections within a document. - The
href
contains two components: the URL, which is the actual link, and the clickable text that appears on the page, called the “anchor text.” - If the href attribute is not present, the <a> tag is not a hyperlink.
Possible URL values
- An absolute URL – points to another web site (like href=”http://www.example.com/default.htm”)
- A relative URL – points to a file within a web site (like href=”default.htm”)
- Link to an element with a specified id within the page (like href=”#top”)
- Other protocols (like https://, ftp://, mailto:, file:, etc..)
- A script (like href=”javascript:alert(‘Hello’);”)
{post_title}
{post_content}
{associated_insight_resource.post_title}
{associated_insight_resource.resource_link}
{associated_insight_resource.insight_type }