What are HTML Tags and Attributes.


Four Letter Tiles
What is HTML Tags and Attributes?


This tutorial has been planned to introduce the basics of HTML code to users who have never written a website by hand. Writing HTML documents is essentially writing tags, attributes, and content. That is why we will focus on explaining how an element, its tags, attributes, and content should be used.

Throughout this document, you can find many elements, attributes, and JavaScript code, which are not properly explained. This is because the goal of this tutorial is to focus on the general syntax and not on the characteristics of each element. For details on HTML 5 elements see the HTML elements list .

ELEMENTS AND LABELS

HTML is a markup language made up of a set of elements that are the basis of its structure. These elements make up a toolbox that authors can use to shape their documents. For example, you can find items that insert paragraphs, videos, or other documents, or items that mark quotes, important text, or the titles of books, movies, works, and other works.

The work carried out by the browsers is vital in this scheme, and they are responsible for the processing and transformation of the elements into represented documents. In this regard, the authors should consider that some elements do not have a tangible representation: their purpose is to provide semantic meanings to the portion of the document they affect. Sometimes the information provided by these semantic elements is used by different types of user agents (browsers, search engines, document processors, etc.) to extract additional information about the document and its parts.

An HTML element is typically made up of two tags: the opening tag and the closing tag. An opening tag consists of the name of the element enclosed by the symbols less-than "<" and greater-than ">". The closing tag is constructed in the same way as the opening tag, but in this case, the element name is preceded by a forward-slash ("/"). In the following example, you'll see the opening and closing tags for the elementb .

Keep in mind that elements are not labels. The elements are represented by tags in the code. However, they are usually considered, wrongly, the same thing.

<b>Important text</b>

Important text

As you can see, there are the opening ("<b>") and closing ("</b>") tags. Now, the text you see in the middle, "Important text", is known as the content of the element. As you progress in learning this language, you will see that some elements are not intended (and are not allowed) to have content. These are the empty elements.

Each of the many elements in HTML 5 has a specific and particular purpose. Some are exclusively semantic, others have an impact on document representation, and still others.

In addition to tags and content, an element can have attributes and events. While attributes define values ​​or properties to be used by browsers in document processing, events can be used to specific behaviors or actions to be performed when certain conditions are met, such as when the user clicks on the element.

Attributes and events share the same syntax: they must be inserted inside the opening tag as a list of items separated by spaces, after the name of the element and preceded by a space. Each of these items is made up of a name (for the attribute or event), the equal sign ("="), and the value or function (sometimes optionally) enclosed in quotation marks. The following example shows an elementb with an attribute ( style) and an event ( onclick).

<b style="color: red" onclick="changeColor(this.parentNode)">Important text</b>

Important text

CONTENT

The content of an element is, broadly speaking, everything between its opening and closing tags. Depending on the element, this can range from absolutely nothing to a chunk of HTML documentThis content is what will be affected by the functionality or meaning of the item. For example, the elementem gives emphasis to your content, and browsers often display your text in a particular font style to make it stand out from the normal text.

Some elements, known as empty elements, are not allowed to have content and their declaration consists solely of the opening tag with any number of attributes and events.

In the following example, there are three elements, each with a different type of content: the paragraph ( elementp ), containing other elements; one word with emphasis ( elementem ), containing only text; and a button ( element input(type = button) ), which is an empty element.

Must Read, HTML Articles

What are HTML Tags and Attributes?

Post a Comment

0 Comments