liveBook · Manning

Hypertext link

As explained in Tiny CSS Projects

A link is an interactive reference that navigates to another resource or location when activated.

A hypertext link takes someone to another resource or location. Use a link for navigation and a button for an action, such as removing an item from a cart. Either can look like a button, but its HTML element should match its purpose: browsers and assistive technologies give the two elements different behaviors and roles. For example, a user can right-click a link to open it in a new tab or window. section 8.2.2

A link that looks like a button

A checkout link can be a primary call to action, while a Continue Shopping link can be secondary. Give links and buttons shared base styles, then use reusable primary and secondary classes for their different colors. Keep visible hover and focus outlines so the controls remain clear during interaction. section 8.2.2

For an icon-based share link, size the link to 48 by 48 pixels and center its 24-pixel icon with flex. A 50% border radius makes the link circular. Add a transparent border before hover or focus; changing its color later will not shift nearby content. section 11.5.3

Listing 11.6 List Item HTML
<li role="menuitem" class="share__menu-item">
  <a href="https:/ /www.facebook.com/sha..."
    target="_blank"
    rel="nofollow noopener"
    tabindex="-1"
    class="share__link"
  >
    <img src="./icons/facebook.svg" alt="Facebook" width="24" height="24">
  </a>
</li>

See how an anchor and its image sit inside a share-menu item. The anchor supplies the destination; the image supplies the visible icon. section 11.5.3

Listing 11.7 Styling the links
.share__link:link,
.share__link:visited {
  height: 48px;
  width: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: solid 1px transparent;
}

Use the link and visited selectors to apply the circular size, centered icon, and transparent border. section 11.5.3

How Tiny CSS Projects covers it

How deep it goes
Explains when to choose a link over a button and works through link styling, without detailing navigation implementation.
Examples
Illustrates icon-based social sharing links and a profile-card link styled alongside a button.
What it assumes
Starts with existing HTML and minimal CSS for the share component, then adds link styling incrementally.
What you can do after
Practice/perform it by choosing a link for navigation and giving it appropriate visual, hover, and focus styles.
How it connects
Connects links to buttons, browser roles, keyboard focus, CSS hover states, and assistive technology.

Also explained in

Compare how 9 books explain hypertext link →

Related concepts

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