Home > Article > Web Front-end > HTML anchors and links_html/css_WEB-ITnose
The difference between A element anchor and link
Anchor and link are both a elements. The only difference is whether there is href attribute.
In Firefox35 and Chrome41, as long as the a element has the name attribute, it is an anchor regardless of whether the name has a value or not. But in IE, if name has no value and no href, it is neither an anchor nor a link.
In all browsers, as long as the a element has the href attribute, it is a link regardless of whether it has a value or not.
Creation and function of anchorThe function of anchor is that when the last part of the URL is #anchorname, the browser will slide the scroll bar so that the anchor appears at the top of the visible window.
Creation method:
When the A element is used as a link, there are Four pseudo-classes: :link, :hover, :active, :visited, respectively corresponding to the four states of stillness, mouseover, clicked and after clicked.
Make the href attribute point to a file. As long as the user clicks, it can trigger the browser to download the file, but this is likely to trigger the browser to open a new window.
The A element in HTML5 has an additional download attribute (assign the href value to this attribute). Use this attribute to download files. The browser does not need it. Open a new window to download the file directly.
The A element has a target attribute. This attribute is not a standard attribute in HTML4 strict mode, but because it is widely used, it has been recognized as a standard attribute in HTML5 property.
The value of the Target attribute should be the name of the frame element, or one of _parent, _top, _self, _blank.
Since target is not a standard attribute in HTML4, if the page complies with W3C standards, it cannot be used directly on the element. But we can use JavaScript to dynamically set the target attribute after the page is loaded.
This is a new feature added by HTML5. HTML5 adds a ping attribute to the A element . The value of the Ping attribute is a string of space-separated URLs. When the link is clicked, the browser will send a POST request to these URLs, indicating that the link has been clicked.
But now only Chrome36 supports it.
Link link
The Link link element has no closing tag, so it is placed in the head element.
Others