Meta tags in HTML are special elements that provide information about a web page. They are placed within the head section of an HTML document and are not visible to users. Meta tags are used to communicate metadata to search engines, browsers, and other web services.
Here is an example of how to add meta tags in HTML using JavaScript:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="This is a concise and structured answer about meta tags in HTML."> <meta name="keywords" content="HTML, meta tags, metadata"> <meta name="author" content="Your Name"> <title>Meta Tags Example</title> </head> <body> <h1>Meta Tags Example</h1> <p>This is an example of using meta tags in HTML.</p> </body> </html>
In the above example, we have added four meta tags:
- The
charset
meta tag specifies the character encoding for the HTML document. - The
description
meta tag provides a brief description of the web page’s content. - The
keywords
meta tag specifies relevant keywords related to the web page’s content. - The
author
meta tag indicates the author of the web page.
These meta tags help search engines understand the content of the page and improve its visibility in search results.