Heim >Web-Frontend >HTML-Tutorial >Meta-Tag in HTML
A meta tag in HTML is used to define data about your webpage or HTML document. With the help of a meta tag, one can define the description of the document, its author information when it was last updated; it uses to give detailed properties of the HTML document. Meta tag is defined within the HTML tag, which included in
part. It is most useful to the web designers to show the actual display part of the web page. The whole viewport control will be done by them using meta tags in HTML 5. The meta tag is referred to by most of the browsers for many useful features like refreshing pages, displaying web pages content, and web services used by them.Syntax
Meta tag used in the head section as follows:
<meta charset="utf-8">
In the above syntax, it states that charset=”utf-8” provides the best support for displaying any kind of language.
Here is another syntax for meta tag with some value is:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
It is used to handle the size of the viewport with all its page dimension value and page scrolling to fit our webpage perfectly on any kind of device.
There are different types of Meta tags used in HTML; let’s see one by one:
1. This is a very basic meta tag used to define any kind of language.
2. It is used to define your content’s description up to 150 words.
3. It is used to preserve all copyrights of defined company.
4. It is used to define abstract of specific webpage.
5. It is used to define author of your HTML document.
6. It is used to define URL address of specific company defined in tag attribute.
7. It is used to handle ratings which comes on our document.
8. If we want to define subtitle for our HTML documents then it made possible using this tag.
9. It is used to refresh our webpage at its defined time spam.
10. It is used to classify our document at defined entity value.
11. This tag is used to specify some keywords in Meta tag, so it’s made possible to search this content easily in our document.
12. This tag is used to define summary of our document.
Meta tag in HTML is mainly used to include machine-readable information in our webpage document, which is actually invisible on the webpage. Another most important work of this tag in HTML is, with the help of this tag, one can easily redirect to the other webpage using this meta tag feature.
There is some attributes list on which meta tag works finely are as follows:
1. Content: Content in the meta tag works like value for its included meta tag.
2. Name: Name works as property for meta tag. It comes in the form of details, owner, keywords, etc.
3. http-equiv: This attribute used to define header details in the document.
4. Charset: It is the main attribute in the Meta tag used to define character encoding for declaration purposes in its document.
5. Scheme: this attribute is used to define the scheme in which the actual meta tag is going to be used. But this type of attribute is not supported in HTML5.
Let’s see some examples
We are going to use the Meta tag, and it will read by the computer system but not able to see anything to the visitors of the webpage.
HTML code:
<html> <head> <meta charset="UTF-8"> <meta name="description" content="Meta tag details information here"> <meta name="robots" content="Robotics"/> <meta name="hotmail:card" content="summary"/> </head> </html>
Output: It will show a blank screen as an output.
Here is this example we are going to use different kinds of Meta tags and show the output; the web page will be refresh at every specific time and store cookies for your page, also mentioning its expiry date.
HTML code:
<html> <head> <title>Meta Tags Example</title> <meta name = "keywords" content = "HTML, Meta Tags, Metadata" /> <meta name = "description" content = "Learning about Meta Tags." /> <meta http-equiv = "cookie" content = "userid = xyz; expires = Tuesday, 31-Dec-19 23:59:59 IST;" /> <meta name = "revised" content = "EDUCBA -Online courses, 3/7/2019" /> <meta http-equiv = "refresh" content = "5" /> </head> <body> <h1>EDUCBA</h1> <h2>Become an Awesome Design Expert</h2> <p>EDUCBA- All about online certification courses</p> <h4>Learn Graphic designing, Animation, Game Development, Video Editing & more with our Online Certification Courses</h4> <p>Choose your interest area and get certified with our online Courses in Finance, Data Science, Software Development, Excel, Design, Project Management, Personal Development, Marketing and Human Resources.</p> </body> </html>
Output: The webpage shown in output will refresh every 5 seconds.
Let’s see another example using meta tags, it will reflect the same as above, but after refreshing the webpage, it will redirect to another webpage which URL’s will be mentioned in the Meta tag as shown in the below HTML code:
HTML code:
<head> <title>Meta Tags in HTML 5</title> <meta name = "keywords" content = "HTML 5, Meta Tag" /> <meta name = "description" content = "Detail description of Meta Tags in HTML 5."/> <meta http-equiv = "refresh" content = "10; url = https://www.educba.com/" /> </head> <body> <p>EDUCBA- All about online certification courses</p> </body>
Output:
So, a Meta tag in Html is used to define metadata about HTML documents. The code included in it is a machine-readable format that works well with a webpage but doesn’t show any content on the page to the visitors. Meta tag containing 3 different types of attributes like global, element-specific, and event handler attributes.
Das obige ist der detaillierte Inhalt vonMeta-Tag in HTML. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!