A Guide to HTML Elements: What They Are and How to Use Them
One of the first things you’ll learn about HTML is that a web page isn’t just one thing; instead, it’s composed of dozens or even hundreds of different components that work together to give you the experience of a website.
These building blocks are known as elements in HTML. HTML components provide extra helpful information to the browser and instruct it on how to display the text, graphics, and other content on the page. You must master the fundamentals of HTML elements to comprehend how websites operate.
We’ll introduce you to HTML elements and show you how to write them in this blog post correctly. A shortened list of some of the most popular HTML components you’ll utilize in your web pages is also provided below. Let’s get going.
What are HTML elements?
A portion of an HTML document is referred to as an element. While some HTML elements identify visible items on a web page, such as text, photos, or buttons, others designate various page sections or offer meta-data about the document.
HTML elements are built with tags directly in the code. The content included within angle brackets (<>) is an HTML tag. For illustration, the HTML paragraph (p) element appears as follows:
|<p>This is an example of paragraph</p>|
The beginning of the element’s content is indicated by the opening (or start) tag (<p> in the preceding example). The closing (or end) tag denotes the point at which the content of the element ends (see above,</p>). A forward slash (/) is added after the first angle bracket in the closing tag, which is the same as the opening tag. Between the opening tag and closing tag of the element, the content is put (This is paragraph text. above). Keep in mind that HTML tags do not care about cases. It would still function if you wrote “p” as “P.” However, because it’s quicker and more logical to write HTML tags in lowercase, most developers do so.
Let’s discuss some of the widely used HTML elements:
Six heading elements are present: h1, h2, h3, h4, h5, and h6. heading elements are utilized to indicate the significance of the text in the webpage. The relevance of the heading increases with the heading’s lower number. For instance, the <h1> element designates the page’s primary heading, and there should only be one of this per page. This aids in search engines comprehending the page’s primary subject. Less important <h2> elements should be placed below the higher level <h1> element.
|<h1>This is a H1 main heading</h1>|
<h2>This is a H2 sub heading</h2>
<h3>This is a H3 sub heading</h3>
<h4>This is a H4 sub heading</h4>
<h5>This is a H5 sub heading</h5>
<h6>This is a H6 sub heading</h6>
A hyperlink to another website or file is created using the anchor (<a>) element. The href attribute, which designates the link’s destination, must also be present in the <a> tag for it to link to another page or file.
The link is created from the text that appears in between the opening and closing <a> tags. Instead of using a general expression like “Click here,” this text should provide a meaningful explanation of the link’s destination. By doing this, users who use screen readers can more easily browse between the different links on a website and comprehend what information each one will link to.
|<a href=”<Write your link here>”> Link </a>|
The most popular tag for adding lines of text to an HTML document is the <p> tag, which stands for paragraph. The use of the <p> tag is compatible with other tags, enabling, among other things, the addition of hyperlinks (<a>) and bold text (<strong>).
<title> This is title of the page</title>
<p> This is a paragraph </p>
<p> This is another paragraph </p>
A paragraph may additionally contain an anchor element (a).
|<p> This is a <a href=”<write your link here>”>link </a></p>|
HTML empty tags
While most of HTML elements contain an opening and a closing tag, certain elements only have a single tag and no content. They are referred to as empty elements.
The line break element, which inserts a line break between text, is one empty element you’ll see frequently. The empty <br> tag is used to create the line break element, as demonstrated below:
|<p> This is first line <br> This is second line </p>|
HTML lists can be either sorted (<ol>) or unordered (<ul>), respectively. One or more list items (<li>) are required in every list.
- Ordered List: List items begin with the <li> tag, and the ordered list begins with the <ol> tag. All of the list items are given numbers in ordered lists.
<li>This is first ordered item</li>
<li>This is second ordered item</li>
- Unordered List: List items begin with the <li> tag and the unordered list begins with the <ul> tag. All of the list items in unordered lists are by default marked with bullets.
<li>This is first bulleted item</li>
<li>This is second bulleted item</li>
Text that differs in some way from the surrounding text is indicated by the i element. Text enclosed by<i>I tags will be shown in italic type by default. The i tag’s main purpose in earlier HTML specifications was to indicate text that should be emphasized. However, tags like “em” and “strong” should be used in modern semantic HTML. To explain how the text in the tags differs from the surrounding text, utilize the class attribute of the <i> element. You could want to demonstrate the text’s or phrase’s foreign language origin:
|<p> This is <i class=”special”>special line</i>.</p>|
GET LIVELY & RESPONSIVE WEB PAGES WITH OUR PSD TO HTML5 CONVERSION !
Contact us with detailed information about the project and get a quote NOW!!!!.
The <img> element is self-closing, so a closing tag is not necessary.
Alternate text for an image is provided via alt tags. The alt tag can be read by visually impaired individuals using a screen reader to help them grasp the image’s meaning.
The optional title attribute will give you more details about the image. When a user hovers over an item, most browsers provide this information as a tooltip.
|<img src=”<Enter source here>” alt=”This is an example image” title=” Example image”>|
But that’s the basic idea: to create a successful page, you must make the most of the tools at your disposal. Of course, using elements is the greatest method of learning how to use them. Therefore, try creating your websites, test various components, and see how they all come together.