What is the meaning of attribute

I am not able to understand what attribute means. For example: Sir said that style is an attribute. Please explain.

Hi @devanshrohilla13 ,
HTML attributes are special words used inside the opening tag to control the element’s behaviour.
For example,

In the code below we use the style attribute
<h1 style="color:hotpink;">Hello Bolt!</h1>
The above code will show Hello Bolt! exclamation in hot pink color. You see, it’s controlling the behaviour of the H1 tag.

There are many other attributes like onclick, onload and more and you will learn most of them in the training.

We also have a <style> tag, to achieve the same thing using the style tag, we can:

<head>
    <style>
        #pink {
            color: hotpink;
        }
    </style>
</head>
<body>
    <div id="pink">
        <h1>Hello Bolt!</h1>
    </div>
</body>
1 Like