Table of contents
1.
Introduction
2.
Definition and Usage  
3.
Syntax
4.
Examples of HTML <address> Tag
4.1.
Example 1: Basic Usage
4.2.
Example 2: Using <address> with Links
5.
Styling the <address> Tag
5.1.
Example 1: Changing Font Style and Color
5.2.
Example 2: Responsive Design for Mobile
6.
Best Practices for Using the <address> Tag
7.
Browser Support  
8.
Frequently Asked Questions
8.1.
Can the <address> tag be used for any text content? 
8.2.
Does the <address> tag affect SEO? 
8.3.
How can I style the <address> tag? 
9.
Conclusion
Last Updated: Jan 18, 2025
Easy

Address tag in HTML

Author Rahul Singh
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The <address> tag in HTML is used to define contact information for its nearest article or body element. This tag is often used to display information like an email address, phone number, physical address, or other contact details. It helps users and search engines identify important contact-related content on a web page.

Address tag in HTML

In this article, we will discuss the syntax, usage, styling options, and best practices for using the <address> tag effectively.

Definition and Usage  

The `<address>` tag in HTML is used to define the contact information of the author or owner of a document or article. It is a semantic tag, meaning it provides meaning to the content it wraps. This tag is not just for displaying addresses; it can also include email addresses, phone numbers, or links to contact pages.  

The `<address>` tag is typically placed within the `<footer>` of a webpage, but it can also be used within an `<article>` to provide contact details specific to that article. It is important to note that this tag should not be used for arbitrary addresses, like a random postal address. It is specifically meant for contact information related to the content or the author.  

For example: 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Address Tag Example</title>
</head>
<body>
    <article>
        <h1>About the Author</h1>
        <p>This article was written by John Doe, a web developer with over 5 years of experience.</p>
        <address>
            You can contact John at <a href="mailto:johndoe@example.com">johndoe@example.com</a>.<br>
            Visit his website at <a href="https://johndoe.com">johndoe.com</a>.<br>
            Or reach out to him at:<br>
            123 Main Street,<br>
            City, State, ZIP Code.
        </address>
    </article>
</body>
</html>


Output

Output

In this example, the `<address>` tag is used to provide John Doe’s contact information. It includes his email address, website link, & physical address. The `<a>` tag is used to make the email & website clickable, which enhances user experience.  

The `<address>` tag is styled differently by default in most browsers, usually displaying the content in italics. However, you can override this styling using CSS if needed.  

Syntax

The syntax of the <address> tag is simple. Here’s how it looks:

<address>
  Contact Information
</address>

 

  • The <address> tag is a block-level element by default.
     
  • It is usually used to wrap text that represents contact information, like names, addresses, email IDs, and phone numbers.

Examples of HTML <address> Tag

Here are a few examples demonstrating how to use the <address> tag effectively:

Example 1: Basic Usage

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Address Tag Example</title>
</head>
<body>
  <h1>Company Contact Information</h1>
  <address>
    Coding Ninjas,<br>
    123 Tech Park,<br>
    New Delhi, India<br>
    Phone: +91-12345-67890<br>
    Email: info@codingninjas.com
  </address>
</body>
</html>


Output

Output
  • The contact details of "Coding Ninjas" are semantically wrapped within the <address> tag.
     
  • Line breaks (<br>) ensure the information is displayed neatly.

Example 2: Using <address> with Links

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Address with Links</title>
</head>
<body>
  <h1>Contact Us</h1>
  <address>
    <a href="mailto:support@codingninjas.com">support@codingninjas.com</a><br>
    <a href="tel:+911234567890">+91-12345-67890</a>
  </address>
</body>
</html>


Output

Output
  • The <a> tag inside <address> makes the email and phone number clickable.
  • "mailto:" and "tel:" are used for email and phone links, respectively.

Styling the <address> Tag

The <address> tag inherits default browser styling, often displayed in italic. However, you can customize it using CSS to match your website’s design.

Example 1: Changing Font Style and Color

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Styled Address</title>
  <style>
    address {
      font-style: normal;
      font-size: 16px;
      color: #333;
      background-color: #f9f9f9;
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 5px;
    }
  </style>
</head>
<body>
  <h1>Office Address</h1>
  <address>
    Coding Ninjas,<br>
    123 Tech Park,<br>
    New Delhi, India<br>
    Phone: +91-12345-67890<br>
    Email: info@codingninjas.com
  </address>
</body>
</html>

Output

Output
  • The address block now has a light gray background, padding, and rounded corners.
     
  • The font style has been changed to normal for better readability.

Example 2: Responsive Design for Mobile

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Responsive Address</title>
  <style>
    address {
      font-size: 1.2rem;
      line-height: 1.6;
      margin: 10px;
    }
  </style>
</head>
<body>
  <h1>Reach Us</h1>
  <address>
    Coding Ninjas,<br>
    123 Tech Park,<br>
    New Delhi, India<br>
    Phone: +91-12345-67890<br>
    Email: info@codingninjas.com
  </address>
</body>
</html>

Output

Output
  • Larger font size and proper spacing ensure the <address> tag looks good on all screen sizes.

Best Practices for Using the <address> Tag

  1. Use for Contact Information Only:
    • Reserve the <address> tag strictly for contact details. Do not misuse it for unrelated information.
       
  2. Avoid Redundancy:
    • Keep the content concise. Use it only where contact details are required.
       
  3. Combine with ARIA Roles:
    • Use ARIA roles like role="contentinfo" for better accessibility.
       

Example:

<footer>
  <address role="contentinfo">
    Coding Ninjas,<br>
    New Delhi, India<br>
    Email: info@codingninjas.com
  </address>
</footer>


4. Provide Fallback:

Include alternative text or links for accessibility purposes, ensuring everyone can access the contact information.

5. Semantic Grouping:

  • Wrap the <address> tag in a <footer> or <section> for a better document structure.

Example:

<footer>
  <address>
    Contact us: <a href="mailto:info@codingninjas.com">info@codingninjas.com</a>
  </address>
</footer>

Browser Support  

The `<address>` tag is widely supported across all modern web browsers, including Chrome, Firefox, Safari, Edge, & Opera. This means you can use it confidently in your projects without worrying about compatibility issues. However, it’s always a good practice to test your code in multiple browsers to ensure consistent behavior.  

To check how the `<address>` tag renders in different browsers, you can use the following simple HTML code:  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Browser Support for Address Tag</title>
</head>
<body>
    <h1>Contact Information</h1>
    <address>
        Email: <a href="mailto:example@example.com">example@example.com</a><br>
        Phone: +1 234 567 890<br>
        Address: 456 Elm Street, City, State, ZIP Code.
    </address>
</body>
</html>


Output

Output

When you open this code in different browsers, you’ll notice that the content inside the `<address>` tag is displayed consistently. By default, most browsers render the text in italics, but this can be customized using CSS.  

For example, if you want to remove the italic styling & add your own custom style, you can use the following CSS:  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom Styling for Address Tag</title>
    <style>
        address {
            font-style: normal; /* Removes italic styling */
            font-family: Arial, sans-serif;
            color: 333;
            background-color: f9f9f9;
            padding: 10px;
            border-left: 4px solid 007BFF;
        }
        address a {
            color: 007BFF;
            text-decoration: none;
        }
        address a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <h1>Contact Information</h1>
    <address>
        Email: <a href="mailto:example@example.com">example@example.com</a><br>
        Phone: +1 234 567 890<br>
        Address: 456 Elm Street, City, State, ZIP Code.
    </address>
</body>
</html>


Output

In this example, the `<address>` tag is styled with a custom font, color, & background. The links inside the address are also styled to match the design. This demonstrates how you can customize the appearance of the `<address>` tag to fit your website’s theme.  

Frequently Asked Questions

Can the <address> tag be used for any text content? 

No, the <address> tag should only be used for contact information related to the website, a person, or an organization.

Does the <address> tag affect SEO? 

Yes, using the <address> tag correctly helps search engines understand your content better, improving your website’s SEO.

How can I style the <address> tag? 

You can style the <address> tag using CSS. For example, you can change its font, color, padding, and background to match your site’s theme.

Conclusion

The <address> tag is a valuable HTML element for presenting contact information in a semantic and organized manner. With proper usage, styling, and adherence to best practices, it can enhance the accessibility and user experience of your web pages. 

Live masterclass