In addition to the standard common properties of html, the link element also includes many optional properties: charset, href, hreflang, media, rel, rev, target, title and type . Among these properties, target is only allowed to be used in two types of dtds, transitional and frameset, and the others can be used in three types of dtds, strict, transitional and frameset.
Among these properties, the rel property is the core. In this article, web design introduces some rel attributes you know and the processing of some link elements in wordpress, which is suitable for beginners to learn.
The most common use of link tags is to call external style sheets, for example:
<link rel=stylesheet href=http://paranimage.com/wp-content/themes/v5/style.css type=text/css media=screen />where href is the URL of the target document, type specifies the Mime type of the target url, and media specifies what device the document will be displayed on.
The following webdesignerwall style sheet call specifies the css style when the document is displayed on the printing device:
<link rel=stylesheet href=http://www.webdesignerwall.com/wp-content/themes/wdw/print.css type=text/css media=print />You may also see stylesheet calling codes on some web pages such as the following:
<link rel=alertnate stylesheet href=http://paranimage.com/wp-content/themes/v5/red.css type=text/css media=screen />This code defines a replaceable style sheet that is used simultaneously with the first link element, the first defines the preferred style, and this allows the user to choose the replaced style. However, this replacement operation requires the browser to support it, but many browsers such as ie do not support it.
Therefore, when using web pages that replace styles, they generally use some style sheets to switch js, allowing users to freely switch interface styles. Everyone should have seen this, and some websites will define multiple colors for web pages. If you are interested in wordpress users, you can download small potato 's wpdesigner7 wordpress theme trial research (or check demo), which uses a simple js and multiple replaceable styles to allow users to change the color scheme of the web page. For slightly higher-level ones, you can also use js to change styles over time, such as bright colors during the day and dark colors at night.
Note : Specifying media=all for the preferred style and adding a print style will be more consistent with the web standards (although for ordinary websites, there will not be many people who want to print your page). The Palan image has no printing style defined, so I will take time to do it later Note : Whether to use alternative styles is a question worth considering. If you only change the color scheme and the overall main tone remains unchanged, it is acceptable. But some friends, such as wordpress users, will enable multiple themes with completely different styles, and then use plug-ins to allow users to change freely. This seems pretty cool, but my advice is never to do that. Not to mention whether it affects SEO, it will make people lack a fixed image perception of your website.For a detailed introduction to the favicon/favorite icon, you can check Baidu Encyclopedia (1, 2), and use the following code to call it.
<link rel=shortcut icon href=http://paranimage.com/wp-content/themes/v5/images/favicon.ico type=images/x-icon/><link rel=icon href=http://paranimage.com/wp-content/themes/v5/images/favicon.png type=images/png/>I am still a little confused about this call. The result of my experiment is:
iPhone or iPod touch devices allow users to add links to the home screen. Use the following code to specify an apple touch icon for your website:
<link rel=apple-touch-icon href=http://paranimage.com/wp-content/themes/v5/images/apple-touch-icon.png />The size of the icon is 57*57 png format. If not, it will automatically scale. If I am not mistaken, it does not have to be made into a beautiful rounded corner like the iPhone style. The iPhone will automatically turn the icon into a rounded corner gradient according to its style, such as the apple touch icon of last.fm.
For domestic users, there are not many people using iPhones. Even if there are many, will your website be placed on the home screen? That's probably not something that ordinary small websites like us can do. But it's fun, I made one for my website and added this link element.
Below is the definition of the wordpress default theme for rss2 address, atom address and pingback address. I think the specific principles are profound and complex, so I won’t study them. Anyway, your blog needs it, so it seems that atom is OK?
<link rel=alternate type=application/rss+xml title=<?php bloginfo('name'); ?> rss feed href=<?php bloginfo('rss2_url'); ?> /><link rel=alternate type=application/atom+xml title=<?php bloginfo('name'); ?> atom feed href=<?php bloginfo('atom_url'); ?> /><link rel=pingback href=<?php bloginfo('pingback_url'); ?> />If you have the function <?php wp_head(); ?> in your topic, the following two link elements will appear:
<link rel=edituri type=application/rsd+xml title=rsd href=http://localhost/wordpress/xmlrpc.php?rsd /><link rel=wlwmanifest type=application/wlwmanifest+xml href=http://localhost/wordpress/wp-includes/wlwmanifest.xml />These two elements are mainly for remote publishing, such as using desktop blog editors such as Windows Live Write to publish articles. If you don't need this function, you can completely delete these two elements. The way to delete it is to open the functions.php of your wordpress theme, and insert the following code before the <?php } ?> or ?> tag at the bottom:
remove_action('wp_head', 'rsd_link');remove_action('wp_head', 'wlwmanifest_link'); Note : You may be thinking that since the <?php wp_head(); ?> function generates these two things, just delete them. Yes, if you expect any other plugin you will not need to get this function, then delete it.Google, Yahoo and live search announced support for a new attribute canonical of link around February this year, with the main function of specifying authoritative links for web pages to solve the problem of duplicate content.
For a detailed introduction to this attribute, please see the Specify Your URL Paradigm in Google Chinese Webmaster.
Here are two plugins that mainly recommend for wordpress users to add this property to your head part: seo no duplicate or canonical url 's. It's easy to use.
It is said to be a full analysis, but in fact, it is just a few commonly used ones, which is enough for most people. If you also know other important and commonly used rel attributes, you are welcome to share them.