HTML <meta> Element

Publish in HTML Tutorial el 25/05/2025 13:48

The <meta> tag is a crucial HTML element that provides metadata about an HTML document. Metadata is information about the data in your webpage that isn't displayed to users but is vital for browsers, search engines, and other web services.


Meta elements are typically placed inside the <head> section of an HTML document and can specify character encoding, viewport settings, author information, keywords, descriptions, and more. They play a significant role in SEO and how your page is displayed on different devices.


Basic Meta Tag Syntax


Common Meta Tag Attributes

  • charset: Specifies the character encoding (e.g., UTF-8)
  • name: Specifies the type of metadata (e.g., viewport, description, keywords)
  • content: Provides the value for the metadata
  • http-equiv: Used for HTTP header information (e.g., refresh, content-type)


Meta Tag Examples

1. Basic Character Encoding

This essential meta tag declares the document's character encoding:

Play Code


2. Responsive Viewport Settings

This meta tag is crucial for responsive design on mobile devices:

Play Code


3. Page Description for SEO

This meta tag provides a description that search engines may display in results:

Play Code


4. Page Refresh with JavaScript

This example shows how to use meta tags with JavaScript for page refresh:

Play Code


5. Dynamic Meta Tags with JavaScript

This example shows how to modify meta tags dynamically with JavaScript:

Play Code


Meta Tag Tips and Tricks

  • Always include the charset meta tag as the first element in your <head> section
  • For SEO, craft unique and compelling descriptions for each page
  • Use the viewport meta tag to ensure proper mobile rendering
  • Consider using Open Graph meta tags for better social media sharing
  • Be cautious with refresh meta tags as they can negatively impact user experience
  • You can use multiple meta tags with different attributes on the same page


Advanced Meta Tags

Here are some advanced meta tags you might find useful:

Meta tags are powerful tools that can significantly impact how your website is perceived by both users and search engines. Use them wisely to enhance your site's functionality and visibility.

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...