HTML Elements
In HTML, an element is a piece of content that is enclosed between a start tag and an end tag. Tags are the instructions you give to the browser on how to display content. An HTML element usually consists of:
- Opening tag: It marks the start of an element. For example,
<p>
is the opening tag for a paragraph element. - Content: This is the text or media inside the element. For example, the words within a paragraph.
- Closing tag: It marks the end of an element. For example,
</p>
is the closing tag for a paragraph element.
Example:
<p>This is a paragraph.</p>
Here, <p>
is the opening tag, 'This is a paragraph.' is the content, and </p>
is the closing tag.
More Examples of Elements
The <title> Element
The <title>
element specifies the title of the webpage, which appears on the browser tab. It's crucial for SEO and user navigation.
<title>Introduction to HTML</title>
The <body> Element
The <body>
element contains all the content that is visible to users, such as text, images, and links. Everything within the body tag is rendered on the webpage.
<body>
<p>Welcome to my website!</p>
</body>
The <p> Element
The <p>
element defines a paragraph. It's used for blocks of text, and browsers automatically add some space before and after each paragraph.
<p>This is a paragraph of text.</p>
In conclusion, HTML elements helps you structure your content in a way that's meaningful and accessible to users.