HTML5: What is the correct way to write address in a HTML document?
Solution :
HTML Code :
<!-- Declare the document type as HTML5 -->
<!DOCTYPE html>
<!-- Start the HTML document -->
<html>
<!-- Start the head section containing metadata about the document -->
<head>
<!-- Set the character encoding to UTF-8 -->
<meta charset="utf-8">
<!-- Set the title of the document -->
<title>What is the correct way to write address in an HTML document</title>
<!-- Close the head section -->
</head>
<!-- Start the body section containing the content of the document -->
<body>
<!-- Use the <address> element to define contact information or author details -->
<address>
<!-- Line break and address lines -->
Address: 50, ABCD Road<br>
New York city<br>
USA.
</address>
<!-- Close the body section -->
</body>
<!-- Close the HTML document -->
</html>
Explanation:
The above HTML code defines a basic HTML5 document with metadata in the head section and a body containing an <address> element that presents address information with line breaks for better formatting.
Here's a brief explanation of each part of HTML code:
- <!DOCTYPE html>: Declares the document type as HTML5.
- <html>: Marks the beginning of the HTML document.
- <head>: Contains metadata about the document, such as character encoding and the title.
- <meta charset="utf-8">: Sets the character encoding to UTF-8.
- <title>What is the correct way to write an address in an HTML document</title>: Sets the title of the HTML document.
- </head>: Closes the head section.
- <body>: Contains the actual HTML document content.
- <address>: Defines contact information or author details in the HTML document.
- Address: 50, ABCD Road<br> New York city <br> USA.: Provides address information with line breaks (<br>) to structure the content.
- </address>: Closes the <address> element.
- </body>: Closes the body section.
- </html>: Marks the end of the HTML document.
Live Demo :
See the Pen address-tag-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics