Skip to content

What are Attributes in HTML and What are the types elements of HTML?

  • by

In this post we will learn what are Attributes in HTML and What are the types elements of HTML. But before we begin, we would like to welcome our dear visitors. Thank you.

What are Attributes in HTML?

An HTML attribute is an attribute written in an HTML element, and this attribute can affect the element or its content completely or partially.

Before going into the explanation, you should know that HTML attributes are divided into two types:

  • global attribute
  • element attribute

Global attribute in HTML:

The global attribute can be used in all HTML elements.

element attribute in HTML:

The element attribute cannot be used on all HTML elements; it is a custom attribute and not for all elements.

How to write Attribute in HTML؟

The HTML attribute is written in the opening tag of an HTML element, directly after the element’s name. The HTML attribute consists of a name and a value.

For example:

<DOCTYPE html!>
<html>
  <head>
  </head>
  <body>
    <tag attribute name= "attribute value">
      Content related to the element
    </tag>
  </body>
</html>

For example:

<DOCTYPE html!>
<html>
  <head>
  </head>
  <body>
    <tag
      attribute name
      =
      "attribute value">
       Content related to the element    
    </tag>
  </body>
</html>

The types elements of HTML:

HTML elements are divided into two types:

  • The first type is block elements.
  • The second type is inline elements.

The difference between HTML block and inline elements:

block elements:

Block elements are elements that occupy the entire width when viewed in the browser, and do not allow any other element to share the same line, whether the element is of block or inline type.

Inline elements:

Inline elements are elements that do not need to be fully displayed in the browser, and also allow another inline element to share the same line.

Leave a Reply

Your email address will not be published. Required fields are marked *