liveBook · Manning

Href

As explained in Web Design Playground

An HTML attribute on an anchor element that specifies the destination resource of a hyperlink.

The href attribute gives an HTML link its destination. Think of the <a> element as a signpost: href tells the browser where the sign points when someone clicks it. section 1.16 section 2.22

A link to another page

<a href="wordplay.html">Play with words</a> Here, href points to the local file wordplay.html, while the text between the opening and closing <a> tags becomes the clickable link. section 2.22

Build an href link in a few small steps:

  • Start with an opening <a> tag. section 2.22
  • Add href="destination" inside the tag, using quotation marks around the destination. section 1.16
  • Use a filename for a local page or a full URL for a remote page, then add descriptive link text and </a>. section 2.22
  • Check capitalization carefully in URLs and filenames; a case error can lead to a 404 Not Found result. section 2.22

A link to another website

<a href="http://wordspy.com/index.php">Visit the site</a> This time, href contains the full address of a remote page. Lowercase attribute names are the readable, maintainable convention. section 2.22 section 1.16

01_08.png

View the figure to see href used as an attribute that supplies an anchor’s link address. section 1.16

How Web Design Playground covers it

How deep it goes
Explains attribute syntax and local or remote destinations with examples, while deferring multiple directories and same-page anchors.
Examples
Demonstrates links to wordplay.html and http://wordspy.com/index.php, including clickable descriptive text.
What you can do after
Apply it via HTML by building links to local files or remote URLs with descriptive clickable text.
How it connects
Connects href with HTML attributes, the anchor element, URLs, local files, remote pages, and hyperlinks.

Also explained in

Compare how 3 books explain href →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.