Skip to content

Instantly share code, notes, and snippets.

@rhatano
Created March 11, 2012 22:29
Show Gist options
  • Save rhatano/2018462 to your computer and use it in GitHub Desktop.
Save rhatano/2018462 to your computer and use it in GitHub Desktop.
<a> attributes
href is the first attribute, out of the realistically 2 attributes that you will need. This attribute takes the hyperlink tag, and directs it the url that is assigned to 'href'.
Usage:
<a href="this is your url">This is the text that acts as the link.</a>
#'a section of your webpage' is the attribute that links the hyperlink to a certain portion of the webpage.
It is used in conjunction with the id attribute, and the href attribute which identifies certain portions of your html elements.
<a href="#xxx"> Links to page content.</a>
What this means is that if you for example, have a section of your website identified as, cookies for example;
<p id="cookies">C is for Cookie and Cookie is for me</p>
<a href="#cookies">Cookies are yummy !</a>; clicking on this text, will make the page scroll up or down to display the text that I wrote before, "C is for cookie and Cookie is for me".
href is the first attribute we will be looking at now. This attribute takes the hyperlink tag, and directs it the url that is assigned to 'href'.
You've see this before, used like this:
<a href="this is your url">This is the text that acts as the link.</a>
But now, with the id attribute, we can link to certain elements that we have now assigned a particular identity to. Recalling that the proper syntax for using the created identity is #x, where x is whatever you chose to use to name that element.
<a href="#xxx"> Links to page content.</a>
What this means is that if you for example, have a section of your website identified as, cookies for example;
<p id="cookies">C is for Cookie and Cookie is for me</p>
<a href="#cookies">Cookies are yummy !</a>
Clicking on the resultant text, will make the page scroll up or down to display the text that I wrote before, "C is for cookie and Cookie is for me".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment