<link/> Tag Syntax
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet ...?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
... metadata content ...
<meta http-equiv="..." content="..."/>
... metadata content ...
<title>My Title</title>
... metadata content ...
<meta name="..." content="..."/>
... metadata content ...
</head>
<body>
... flow content ...
<meta itemprop="..." content="..."/>
... flow content ...
</body>
</html>
Rules for coding the HTML link element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
<link/> tag as metadata content
- Code any <link> tags in the <head> section of the HTML document where metadata content is expected.
- Each link element consists of a standalone <link/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlnsattribute on the <html> tag. - Include a
relattribute within the <link/> tag. The value of the attribute, which is enclosed in double quotes, is the type of relationship between the linked resource and the current document. - Include an
hrefattribute within the <link/> tag with the URL of the external resource. - Include any other attributes of the <link/> tag as appropriate.
- Since the link element is a void element, it should always be coded as a self-closing tag terminated with the delimiter string
/>.
<link/> tag for microdata properties
- Code the <link> tag in the <body> section of the HTML document where phrasing content is expected.
- The link element consists of a standalone <link/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlnsattribute on the <html> tag. - Inside the <link> tag, code an
itempropattribute to indicate the link element represents a microdata property. The value of the attribute, which is enclosed in double quotes, is the name or URL of the microdata property. - Inside the <link/> tag, code an
hrefattribute with the value of the microdata property in double quotes. - Include any other attributes of the <link/> tag as appropriate.
- Since the
<link/>tag is a void element, it should always be coded as a self-closing tag terminated with the delimiter string/>.
<link/> Content Model
Contents of the <link/> Tag
Content: Empty. All properties are coded using attributes.
Since the <link/> tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiters /> rather than just > (<link .../>).