3 ms·
I wonder why they recommend putting <link rel="..."> tags into the head, instead of marking up existing <a href> tags (which you'll have in most cases for prev/
by detaro 11y ago
I wonder why they recommend putting <link rel="..."> tags into the head, instead of marking up existing <a href> tags (which you'll have in most cases for prev/next) with rel-attributes. Actual difference in parsing? Just because <a> tags might not be on every site?
- ldjb 11y agoWell, for one thing, it's in the HTML standard [1]. But also consider websites such as forums that allow users to post custom HTML to a page. Although there is often some sanitisation, that often doesn't stretch to removing attributes from <a> tags. In those cases, it might be possible for a user to hijack the sequential links and make them point to some other website. [1] https://www.w3.org/TR/html/links.html#sequential-link-types https://www.w3.org/TR/html/links.html#sequential-link-types
- detaro 11y agoyour link says: The next keyword may be used with link, a, and area elements of course it is allowed to put it in <link>. And if your badly sanitized HTML (which hopefully did strip the malicious onClick handler ;)) includes an <a rel="" href="">, are we sure that parsers will prefer the <link> in the header? Or will Google and others actively ignore the <a>, despite the standard allowing it on both? That would be useful to know. For simple bots putting it in an easy-to-discover link in <head> might be good, but a search engine and a browser both have to parse the entire page anyways...
- tyingq 11y agoI believe it's to unambiguously tie the "next" to the page. Where the page content might have, for example, an <a> that moves images around in a carousel.
- ibejoeb 11y agoThere is only one next in the sequence, but there may be multiple navigational elements that bring the user there. For example, links in both a header and a footer.
- chias 11y agoIf you had to put them on your 'a' tags, it could conflict with other "rel"s. That is, how would one make a link that was both "next" and "nofollow"? (that's probably a bad example, but you get what I'm getting at)
- jonhohle 11y agoSet both: http://www.w3.org/TR/html401/struct/links.html#adef-rel http://www.w3.org/TR/html401/struct/links.html#adef-rel
- tripzilch 11y agoBecause semantics. The location of the "next" page is a property of the entire page, and therefore belongs in the head (similarly, so does the title of the page). It's not a property that may be present in any of the links (or other elements) of the page. There's a whole lot of advantages that follow, but aren't quite reasons why (e.g. like a physical book, I don't need to read the page itself to figure out where the next page is), but it follows from applying the semantics of webpage (meta) data in a consistent manner. (except for a CYOA book)