130 likes | 310 Views
HTML Links. 4 February 2014. Links. Links. Need to define two things: The destination Something to click on to get there Tag is <a href =…>click here</a> Can be text or image Text can be formatted to look different How do you know to click on an image?. The destination .
E N D
HTML Links 4 February 2014
Links • Need to define two things: • The destination • Something to click on to get there • Tag is <a href=…>click here</a> • Can be text or image • Text can be formatted to look different • How do you know to click on an image?
The destination • Always link to ananchor point • Implicit anchor point at top of page • Adding other anchor points • Insert named anchor point • id=“anchor” on any tag • Can also act as a class • But notice that you can only use it once on any page • Can repeat it on multiple pages
Referencing Ids • To point to an anchor point on SAME page <a href=“#anchor”>link text</a> <a href=“#”>top of page</a> • To reference an id in CSS • #idname instead of .classname • All the same forms (one element, any element, context) • Or limit ids to location and classes to format • can have both
On Page Navigation • Long pages • Avoid too much scrolling • Links to subsections • Link to top • Lots of topics • Use a “table of contents” of links
Linking to external pages • Use full url <a href=“http://www.unc.edu">Link text</a> • To force open in a new tab (window) <a href=“http://www.unc.edu” target="_blank"> Link text </a> GOOD PRACTICE REQUIRED IN THIS CLASS
HTML Local Links • Other pages that are always kept with the current one • Not only the same machine, but the same folder • This is why we use folders! • Connect with the same access tag <a href=“other page">Link text</a> (same format as the link statement) <a href=“Page#AnchorPoint”>Link text</a>
Pseudo-elements • Characteristics of tags that can have their own attributes • Not reflected in HTML • In CSS: tag:pseudo-element • Examples: • p:first-line, p:first-letter
Link Pseudo-elements • Link states • a:link -- a normal, unvisited link • a:visited -- a link the user has visited • a:hover -- a link when the user mouses over it • a:active -- a link the moment it is clicked • Note: CSS order important • hover must come after link & visited • active must come after hover a:link { color: #FC5BD4; } a:visited { color: black; }
a in CSS • Can change attributes for all states with a { Property: value; • inheritance rules are not easy to remember: add things explicitly!