<head> and <meta>
<head> and <meta> provide information about the page.
HTML <head> element.
1.HTML <head> element immediately follows the <html> start tag and encapsulates data about the page(i.e metadata).
2.It provides information about the content, markup, stylesheets scripts etc of the document.Usings elements <meta>, <style>, <script>, <noscript>, <base>, <link>.
HTML <head> tag syntax:
HTML <title> element
1.HTML <title > element is the most important and a must element for every webpage.
2.It should be a short description unique to a webpage.It is displayed at the top of the browser tab.
3.It should not contain any links or image within it, just text.Should be a short summary unique to the page in less than 60 characters.
HTML <title> element example :Run The Code » Note-Search engines like Google,Bing etc make use of <title> to know about the webpage contents and accordingly place them in search results.
Base for relative URL.
1.The base element acts has a base for all relative links to be resolved in the document.
2. It also specifies how the links open when clicked and also how the forms data be submitted. It prevents redundant typing of the same URL over and over again while adding links.
3. The attributes href and target attribute are used to specify the link address and how the links open respectively.
Syntax :Run the Code»
HTML <meta> Element
1.HTML <meta> element enables you provide additional information about the webpage like author, keywords, page-refresh etc.
2.The <meta> element must be enclosed within the <head> tags, and always appear in the form of name="value" pairs.Note-Meta element is a void element hence end tag is forbidden.Also contents within meta are not visible on webpage,but useful while parsing the document.
Meta:name and content
1.The use of name attribute is to name a metadata for the document.It is always associated with a value defined within the attribute content.
2.The values corresponding to each name is declared within the content attribute.
Table:Predefined metadata names and descriptions.
|application-name||Defines the name of the current web application running on the web document.|
|author||To denote the author of the current web document in free form.|
|description||A short desciption or summary of the web document.Max-length is 155 characters.|
|generators||To denote the software that generated the webpage, in free format.Eg: Asp.net, php.|
|keywords||To denote relevant keywords associated with page contents, multiple keywords are seperated by commas.|
Predefined metadata Types example.Note-Other than these predefined five name types you can use any other metadata extensions.
Metadata extension: robots
1.A very common metadata extension robots is used to denote whether search engines should cache the page for their search results or not.
2.The value "noindex" denotes that the page should not be indexed
3.The value "nofollow" denotes that the search engines should cache the webpage, but not the links within the webpage
4.The value "noarchive" denotes that the search engines should not cache the copy of webpage in search results.
Metadata Robots syntax:
1.Metadata attribute http-equiv is used to give pragma directives to the webserver on how a webpage should be served.
2.The http headers can be overrided using http-equiv attribute and simulate response headers.
1.The metadata attribute charset defines the character encoding of the stml webpage.However an elements language attribute overrides it under a local enviornment.
2.The most common value is UTF-8 for Unicode.You can use other values like UTF-16, ISO-8859-1(for latin characters), but most browsers do not support all encoding types.