HTML Attributes
Chapter 4
HTML Attributes provide additional information about HTML Elements behavior.
Each HTML Element have HTML Attributes.
Different HTML Elements can have same or different HTML Attributes.
We always have HTML Attributes in start tag.
Usually HTML Attributes come in key - value pair like width="100%"
Let's have some examples
<img src="image-path" width="100%" height="50%" />
In above example src
, witdh
and height
are image tag attributes.
Width and Height define image size and src define which image need to show. We will learn more image attribute in HTML Images Chapter
<h1 style="color:red" /> I am red Text </h1>
In above h1
element style
is a attribute. Style attribute can be used to add a style to a HTML element.
We can change color, size, position and more using style attribute. In this example text color will be red.
We will learn more about style attribute in HTML Styles
Note: Browsers add default styles to each HTML Element which we can overwrite using Styles Attribute or CSS.