These attributes are contained in the opening tag of an element and are usually in name=value
pairs where the attribute value
is the value of the attribute contained in either single or double quotes. Nevertheless, there are some attributes that do not have values (For the purpose of this tutorial, we shall call them empty
Non - empty attributes
<h1 id='bighead' style='color:red;'>Welcome to My Page</h1>
Above, we can see examples of HTML attributes extending the <h1> element by assigning a unique id (using id
attribute) and some styling (using style
attribute) to the element.
<input type='radio' checked/>
Above, we can see examples of empty attributes (controls
HTML have a lot of predefined attributes. Some are general attributes usable on all HTML elements like the:
While some are limited attributes usable on a handful of elements like the:
for form elements
for link elements
for multimedia elements.
As you continuously engage in learning and creating HTML pages, you will get familiarized or acquainted with more of HTML attributes.
- Attributes gives more information about HTML elements. For example, the id attribute giving a unique id to an element.
- They also give information to HTML elements to help them display properly. For example, the style attribute giving styles that should affect an element.
- Attributes are contained in the opening tags of elements in name=value pairs. For example,
<p attributeName="attributeValue">Hello World</p>
- An HTML attribute value should be contained in single or double quotes. This helps separate the value from other texts or attributes.
- You can have as many attributes as you want on an element.
<a href='' style="" id="" class="">Go</a>