HTML Meta Tags
Meta tags are essential for search engine optimization (SEO) and social media sharing. They provide information about the webpage, such as the title, description, and author. This tutorial covers the most common meta tags and their attributes.
Example code
Below is an example HTML code snippet that includes various types of <meta> tags commonly used:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- Character encoding -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Responsive design -->
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Internet Explorer compatibility -->
<meta name="description" content="This is a description of the web page" />
<!-- Description for search engines -->
<meta name="keywords" content="HTML, CSS, JavaScript" />
<!-- Keywords for search engines -->
<meta name="author" content="Your Name" />
<!-- Author name -->
<title>Document</title>
</head>
<body>
<!-- Your content here -->
</body>
</html>Explanation of each meta tag
- Character Encoding (charset):
<meta charset="UTF-8">sets the character encoding for the webpage. UTF-8 is the most common and recommended. - Viewport:
<meta name="viewport" content="width=device-width, initial-scale=1.0">sets the viewport to scale the page to the screen width, useful for responsive design. - IE Compatibility:
<meta http-equiv="X-UA-Compatible" content="ie=edge">specifies that the page should be rendered using the latest rendering engine available on Internet Explorer. - Description:
<meta name="description" content="This is a description of the web page">provides a brief description of the webpage, which search engines may use in search results. - Keywords:
<meta name="keywords" content="HTML, CSS, JavaScript">specifies keywords for the webpage, which were historically used by search engines but are less relevant today. - Author:
<meta name="author" content="Your Name">indicates the name of the author of the webpage.
How to add favicon in HTML
A favicon is a small icon that appears next to your website's title in browser tabs. It helps in branding and easy identification among multiple tabs.
Step 1: Create/Choose favicon
Make a square image, usually 16x16 or 32x32 pixels, in .ico format. You can create a favicon from this website: favicon.io.
Step 2: Add favicon to your HTML
Place the .ico file in your website's root directory, where index.html is located.
Step 3: Update HTML
Insert the following code in the <head> section of your index.html file:
<link rel="icon" href="favicon.ico" type="image/x-icon" />Replace favicon.ico with your file's path if different.
Step 4: Test
Open your website in a browser, and you should see the favicon in the browser tab.
Conclusion
Meta tags play a crucial role in providing information about your webpage to search engines and social media platforms. By including relevant meta tags, you can improve your website's visibility and user experience. Additionally, adding a favicon enhances your website's branding and user recognition. Remember to keep your meta tags up-to-date and relevant to ensure optimal performance and engagement.
How is this guide?
Sign in to share your feedback
Help us improve by sharing your thoughts on this guide.
Last updated on