what is the html tag for a link?

Dani AI

Generated

Two things are often meant by "link" in HTML. was pointing to the element you use to make clickable hyperlinks (the inline element that takes an href); was pointing out the separate element used to associate external resources (stylesheets, icons, preloads) with the document. See the MDN reference for the anchor element and the link element for the exact attribute details and placement (MDN: a element, MDN: link element).

Practical tips beyond the basics: use meaningful link text (avoid "click here") so purpose is clear to assistive tech and search engines (WCAG guidance). When opening a new tab, add the appropriate rel values to mitigate window.opener security issues (see guidance on using rel=noopener). Prefer HTTPS targets, avoid javascript: URIs, use mailto: and tel: schemes for email/phone where appropriate, and ensure file downloads have correct server headers so browsers handle them right.

A minimal CSS pattern for link states and visible keyboard focus:

a:link { color: #0066cc; }
a:visited { color: #551a8b; }
a:hover, a:focus { text-decoration: underline; }
a:focus { outline: 3px solid #ff9900; outline-offset: 2px; }

For security details on opening external links see web.dev: rel=noopener guidance.

Recommended Answers

All 3 Replies

It would be

              <a href="url">Link text</a>

You could have googled that BTW....

I am assuming that ibra.kitandwe is really asking about an anchor (hyperlink). So just to clarify, there is an HTML element for a link, not to be confused for an anchor.

You can use the link element to define the relationship between a document and an external resource, such as a style sheet. For example...

<link rel="stylesheet" type="text/css" href="style.css">

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.