In this note, we are going to learn about HTML Elements, their structure and types as well. Welcome to Poly Notes Hub, a leading destination for engineering notes for diploma and degree engineering students.
Author Name: Arun Paul.
Overview of HTML Elements
An HTML element is a component of an HTML document that defines a structure or a section of material on a web page.
Every HTML element consist of:
- Tags: The opening and closing tags specify where the element begins and ends.
- Content: The information or nested items inside the tags.
- Attribute: Additional information or settings for the element are included within the opening tag.
Structure of an HTML Elements
It has main three part as shown on the above picture:
- Start Tag: In the above picture, we are using paragraph tag <p> as a start tag or opening tag.
- Content: “Welcome to Poly Notes Hub”, is the content between both of the tags, In between, <p>Content</p>.
- End Tag: The end tag is </p>
Types of HTML Elements
There are two types of HTML Elements:
- Block Elements: These elements cover the entire width of their parent container and always begin on a new line. For Example: <div>, <p>, <h1> etc.
- Inline Elements: These items take up only the appropriate width and do not begin with a new line. For Example: <a>, <span>, <img> etc.
Attributes of HTML Elements
Here are some basic attributes:
- id, provides a unique id for an element.
- class, sets one or more class names for an element.
- style, used for inline css.
- title, for additional information of the element.
Examples, that how to use attribute:
<a style="color: red"; class="link-class" id="link-id" title="Example Link">Welcome to Poly Notes Hub</a>