a tags in HTML
a tag is a fundamental HTML element responsible for much of the linking goodn ess that makes HTML great!
Let's take a quick look at how the tag works:
<a href="sourceurl">Displayed Text</a>
As in any tag, there's a basic structure of
<tag attr="value">content</tag>. The fantastic, amazing attribute in the
a tag is
href -- short for "hypertext reference". The
href attribute identifies a target URL; when this HTML snippet is displayed in a browser, the browser will direct you to the URL in the href attribute. Let's try it out:
<a href="https://google.com">Google Owns All Your Data</a>
As with most HTML tags, the
a tag accepts a number of possible attributes. Some of them are used only rarely, but you will often see the
target attribute in the real world. THis allows you to specify where to open the link you click on:
_selfmeans "open here"
_blankmeans "open in a new tab"
_parentmeans "if you're looking at an internal frame, open this link in the frame's arent tab. Otherwise, just open here like in
Try it yourself
You can clone this repository and load a local copy of the tutorial page in your browser to see the tag in action. Then make some changes to the file to learn this yourself!
The Mozilla Developer Network has lots more detail about this and every HTML tag!