Specifying Metadata about a HTML Web Page
As we have discussed earlier in this tutorial, you can specify the title of an HTML web page using the <title> element, which is placed inside the <head> element. You can also specify additional information about an HTML Web page, referred to as metadata, using another element, called as <meta> element, which is also placed inside the <head> element. Using the <meta> element, you can specify information, such as description of the Web page, name of the author of the Web page, and keywords through which search engines can find the Web page. The metadata information is specified in the form of a property/value pair where property is specified using the name attribute and value is specified using the content attribute.
Below list of <meta> Element Attributes :
Attributes |
Description |
---|---|
content |
Adds as an essential attribute, which represents the content (value) of a property/value pair. |
dir |
Gives the direction of directionally neutral text. You can set this attribute to ‘ltr’ for left to right text direction or ‘rtl’ for right to left text direction. |
id |
Specifies the unique alphanumeric identifier for the element, which can be used for referring to it. |
http-equiv |
Connects the content attribute to an HTTP header field. If the browser asks for the Web page, the value of the content attribute is passed to the browser as part of the HTTP header. |
lang |
Specifies the Base language used for the element. |
Name |
Connects the content attribute to a name, such as ‘Keywords’; when a Web browser or other agent request the data connected to the name. the value to the content attribute will be sent. |
charset |
Defines a new attribute used for defining the character encoding in the document by setting value of charset=”utf-8” |
Adding Description of the Web Page
You can add a description of an HTML Web page using the <meta> element. The description that you add about the Web page using the <meta> element is used by search engines for indexing and ranking the Web page. You should note that some search engines also display the description of Web pages together with the search results; therefore, you should try to make your description such that it encourages people to visit your Web page.
Let’s perform following steps to learn how to add description of an HTML Web page:
Open your HTML document in notepad, and add the code, given below:
<!DOCTYPE html>
<html>
<head>
<title>
Title of the web page
</title>
<meta name=”description” content=”A simple HTML Web page to learn”/>
</head>
<body bgcolor="blue" background="C:\Users\Public\Pictures\Sample Pictures\Desert.jpg">
Contents of the web page
</body>
</html>
Save and close the HTML Document.
Specifying Author of the Web page
You can also specify the name of the author of an HTML Web page using the <meta> element. Although specifying the author name does not affect the ranking of your Web page; however, supplying this information helps others to know who has created the Web page and who is responsible to update it.
Let’s perform the following steps to specify the name of the author of an HTML Web page:
Open your HTML document in Notepad, and add the code, given below:
<!DOCTYPE html>
<html>
<head>
<title>
Title of the web page
</title>
<meta name=”description” content=”A simple HTML Web page to learn”/>
<meta name=”author” content=”Manisha Dubey”/>
</head>
<body bgcolor="blue" background="C:\Users\Public\Pictures\Sample Pictures\Desert.jpg">
Contents of the web page
</body>
</html>
Save and close the HTML Document.
Specifying Keywords for Search Engines
You can specify certain keywords for an HTML Web page that are used by search engines for indexing your Web page by using the <meta> element. Search engines use the keywords that you have specified to find and return your Web page, when someone makes a search about the subject relating to these keywords.
Let’s perform the following steps to specify keywords in a HTML Web page.
Open your HTML document in Notepad, and add the code, given below:
<!DOCTYPE html>
<html>
<head>
<title>
Title of the web page
</title>
<meta name=”description” content=”A simple HTML Web page to learn”/>
<meta name=”author” content=”Manisha Dubey”/>
<meta name=”keywords” content=”HTML, HTML 5, Learn HTML 5, Web page ”/>
</head>
<body bgcolor="blue" background="C:\Users\Public\Pictures\Sample Pictures\Desert.jpg">
Contents of the web page
</body>
</html>
Save and close the HTML Document.