When writing HTML code, we create HTML element with HTML tags with <p>
, <h1>
, <h2>
, <a>
and many more. If you want to control the HTML element, we use HTML attributes to provide additional information. At here, we will show you how to add the HTML attributes name and value to the element. To add the attributes, we must add it at the opening HTML tag.
From the image above, you can see the HTML attribute is located in opening HTML tag. You can’t place it at closing HTML tag or anywhere else.
The href Attribute
Let me show you one example over here. When creating the hyperlink for HTML document, we use <a>
element. The <a>
itself won’t provide the redirection of the web page. At here, we need to add the href
attribute and make the hyperlink redirect to my website.
<a href="https://blog.jorcus.com">Welcome to Jorcus.com</a>
As you can see, the HTML attributes are use for adding additional information to the HTML element to do whatever user want to the element.
Useful Attributes
There are also some important attributes that you must know about them because you might use it almost all the time.
id
class
style
The attributes related to CSS. It’s a style sheet for HTML, I don’t want to confuse you with this tutorial. So, it’s recommend u click on the link on the text for more information.