HTML Element: a

Date:


Example

Syntax

1
<a href="https://tutsplus.com">Envato Tuts+</a>

Result

Linking to Sections

Anchors can also link to sections on the same page by using fragment identifiers. This takes the form of a # symbol which points to the id of an element elsewhere on the page:

1
<a href="#somewhere">Jump somewhere else</a>
2

3

4

5
<h2 id="somewhere">This is somewhere else!</h2>

For example, here’s a link to jump to the Learn More section below!

You can use #top or simply # to link directly to the top of the current page.

Browser Support

The <a> tag is supported in all modern browsers. Read more on caniuse.com.

Attributes

The <a> tag supports Global Attributes in HTML. Global Attributes are common to all HTML elements and can be used on all of them (though they may not have much of an effect on some of them).

  • If the <a> element has an href attribute, then it represents a hyperlink labeled by its contents.
  • If the <a> element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed.

The href Attribute

The <a> element supports the following attributes which can only be present if the href attribute is present:

Content

An <a> element allows for transparent content, but there must be no interactive content descendant, <a> element descendant, or descendant with the tabindex attribute specified.

Accessibility

Wherever possible, make link text descriptive, rather than simply saying “click here”. For more information check out Emma Patricios’ article on creating valid and accessible links (see what I did there?).

  • The <link> element is also a type of hyperlink, but instead of being used to navigate HTML documents and files, it’s used to define a relationship between them.

Learn More



Source link

About Author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Share post:

Subscribe

spot_imgspot_img

Popular

More like this
Related

UIBundle: A One-Stop Shop for Design Resources, Freebies, & Tips

Every designer has a favorite website where...

Collective #784

State of HTML 2023 * Nue * The...

How to Create CSS Ribbon Shapes with a Single Element — SitePoint

In this article, I’ll show you how to...

Market Test: Get Real Human Feedback on Your Designs

Conjointly’s Market Test is a suite of...