HTML Elements and Attributes

HTML Elements and Attributes

Hypertext Markup Language, or HTML, is the basic foundation of web development💻. It is the standard markup language for building websites and web-based applications. The building blocks of web pages are the elements of HTML, which provides the structure 🏗️ for the website 🌐. In this post, I'll explain HTML elements and attributes in more detail and show you how to use them to create web pages📃.

🤔What is an HTML Element 🧱?

HTML elements are the building blocks of an HTML document, such as a heading, a paragraph, an image, or a link, elements are defined by tags. An HTML element consists of a start tag, an end tag, and the content in between. For example, a paragraph element is represented by the <p> start tag and the </p> end tag, with the content of the paragraph appearing between these two tags.

<p>This is a Paragraph.</p>

🤷‍♂️ How to Use HTML Elements?

HTML elements are used to structure 🏗️ the content of a web page. To use an HTML element, you must open the tag <tagname> and then close it </tagname>. The closing tag is the same as the opening tag, but with a forward slash / before the keyword, like this </h1>. The content of the element goes between the opening and closing tags.

<tagname> This is content </tagname>

😑 Empty HTML Elements </>

HTML elements with no content are called empty elements. The <br> tag defines a line break, and is an empty element without a closing tag :

<p> This is a <br/> paragraph with a line break. </p>

💬HTML Elements Types 💫

Headings, paragraphs, lists, links, photos, tables, forms, and more are just a few of the many distinct kinds of HTML elements.

Here is a list of popular and most useful HTML elements:

<html>

Defines the root of a HTML document

<head>

Contains information about the document, such as the title, meta

<body>

Contains the main content of a HTML document

<header>

Represents a container for introductory content or a set of

<nav>

Represents a section of a page that contains navigation links

<main>

Represents the main content of a document

<footer>

Represents a container for the footer of a document or section

<h1> to <h6>

Defines headings of different sizes and importance

<p>

Defines a paragraph of text

<ul>

Represents an unordered list of items

<ol>

Represents an ordered list of items

<li>

Represents a list item

<img>

Embeds an image in a document

<a>

Defines a hyperlink to another web page or a specific location on the same page

<form>

Represents a form for user input

<input>

Represents various types of input controls, such as text fields, checkboxes, and radio buttons

<select>

Represents a drop-down list of options

<textarea>

Represents a multi-line plain text editing control

<button>

Represents a clickable button

<table>

Represents a table of data

👁‍🗨What are HTML Attributes? 🔖

HTML attributes are properties that provide additional information about an HTML element. Attributes are added to the <> opening tag of an element, which typically has a name and a value. The src attribute, for example, is used to define the source of an image element, as in the following example :

<img src="image.jpg" alt="An Example Image" />

There are many different types of HTML attributes, including the following:

AttributesDescription
idSpecifies a unique id for an element.
classSpecifies one or more class names for an element.
styleSpecifies inline CSS styles for an element.
srcSpecifies the source of an image element.
altSpecifies alternative text for an image element.
hrefSpecifies the destination URL for a link element.
targetSpecifies where to open a link.

Conclusion 🧐

HTML elements are the building blocks of the web and are essential for creating web pages and web applications. By understanding the different types of HTML elements, tags, and attributes, and how to use them, you can start building your website with practice and a solid understanding of HTML.

Thank you for taking the time to read this article😊. If you found it helpful, I would greatly appreciate it if you could give it a like 👍 and share 🔁 it with your friends.