HTML A Tag

Posted The: 21/05/2008 At: 13:54

Last Edited: 15/08/2008 At: 18:49

Contents:

The A Element is used to create links/anchors. You may also find the Tutorial entry Images and Links useful.

Note: Links are inline-elements, and needs to be inclosed in either <p> tags, or other block-level elements. I.E. (One of P, H1-H6, DIV, ADDRESS).

Example:

Note. For accessibility reasons its best to separate links with something like "-", or inclose them in unordered/ordered lists.

The first is just a single link, inclosed in p tags.

<p><a href="http://www.brugbart.com/">Brugbart in English</a></p>

The next is two links, (can be multiple), again inclosed in a single p element, but this time separated by "-".

<p><a href="http://www.brugbart.com/">Brugbart in English</a> - <a href="http://www.brugbart.dk/">Brugbart in Danish</a></p>

The last example is best for navigation menus, and incloses the links in li elements. In this case in an unordered list.

  <ul>
   <li><a href="http://www.brugbart.com/">Brugbart in English</a></li>
   <li><a href="http://www.brugbart.dk/">Brugbart in Danish</a></li>
   <li><a href="http://www.blueboden.com/">BlueBoden</a></li>
  </ul>

If using images as links, don't forget to make sure, that the links are accessible. Its a good idea to use the alt tags, since this will be what a screenreader reads when they encounter images as links.

Comments: [0]

© Brugbart Webdesign