HTML Attributes
HTML attribute is a additional information about the HTML element.It is a name value pairs like name="value".Attributes is always place inside start tag of the HTML element.
HTML attribute is a additional information about the HTML element.It is a name value pairs like name="value".Attributes is always place inside start tag of the HTML element.
HTML Attributes has been put inside start tag of an HTML element.Do not place HTML attribute inside closing tag of any HTML element.
The <a>
tag has a href
attribute that contains the URL of the connected web page.
<a href="https://sudhakarinfotech.com/shop">Visit sudhakarinfotech</a>
<a href="https://sudhakarinfotech.com/shop">Visit sudhakarinfotech</a>
Note: The HTML hyperlink element has href
and title attribute. The href
attribute of the HTML element is used to link the path of another web page while the title describes the web page.
The <img>
tag us basically used to show the images.It has src
attribute that specifies the path URL of the displaying image.
<img src="URL of the image i.e relative or absolute path" >
<img src="URL of the image i.e relative or absolute path" >
Note:The HTML element <img>
has an src
attribute that is used for providing a path of the image.
The is also consists of
width
and height
attributes that specify the width and height of the image respectively.
<img src="URL of the image i.e relative or absolute path" width="width of the image" height="height of the image">
<img src="URL of the image i.e relative or absolute path" width="width of the image" height="height of the image">
Note: The HTML element
has a width
and height
attribute that is used to provide the width and height of the image.
The <img>
has attribute alt
that is very useful during any path error of the image because it displays alt
message when the image does not display on the screen due to server error.
<img src="URL of the image i.e relative or absolute path" alt="Title about image">
<img src="URL of the image i.e relative or absolute path" alt="Title about image">
Note:The HTML <img>
element has an alt
attribute that is used to provide additional information about the image and it displays on the screen whenever the image file path is not loaded by the browser.
The style
attribute is used to add styles to an HTML element,such as font,size,color ,etc.
<p style="color:green; font-size:18px; text-align:center;">This is a red paragraph.</p>
<p style="color:green; font-size:18px; text-align:center;">This is a red paragraph.</p>
This is a red paragraph.
Note:The HTML element <style>
is used for writing inline CSS rule.
The id attribute provides unique identification of the HTML element hence it is very easy to select this element using CSS or JavaScript.
<div id="container">Some content</div>
<div id="container">Some content</div>
Note:The id
attribute of an HTML element is unique and the CSS rule regarding the id
attribute is only applicable to a single element of an HTML document.
The class attribute is also used to identify the element but it is not unique since one class value can be assigned to other elements too.
<p class="flower__text">Let us understand class attribute.</p>
Let us understand class attribute.
Note: The class attribute of an HTML element is used for providing CSS rules to more than one HTML element.