HTML-Attributes in HTML(HTML-4)

 


Attributes in HTML

  • HTML attributes are special values that can be added to HTML elements.
  • They are used to provide additional information about the elements like the appearance, behavior, and functionality of HTML elements.
  • In this blog post, we will take a closer look at some of the most commonly used HTML attributes.

id Attribute:

The id attribute is used to give an element a unique identifier. This attribute is useful for targeting specific elements for use with CSS or JavaScript.(W-1-1)
Example:

(W-1-1)

class Attribute:

The class attribute assigns one or more CSS classes to an element. This attribute is useful for applying styles to groups of elements. (W-1-2)
Example:

(W-1-2)

href Attribute:

The href attribute is used to specify the URL of a link. This attribute is used in the <a> element.(W-1-3)
Example:

(W-1-3)


src Attribute: 

The src attribute is used to specify the URL of an image or other media file. This attribute is used in the <img> element.(W-1-4)
Example:

(W-1-4)

alt Attribute: 

The alt attribute is used to provide a text description of an image. This attribute is useful for screen readers and for users who have disabled or corrupted images in their web browser. (W-1-5)
Example:

(W-1-5)

width/height Attributes:

The <img> tag should also contain the width and height attributes, which specify the width and height of the image (in pixels):(W-1-6)
Example:

(W-1-6)

style Attribute:

The style attribute is used to apply inline CSS styles to an element. This attribute is useful for making quick, one-off style changes to an element. (W-1-7)
Example:

(W-1-7)


target Attribute:

The target attribute is used to specify where to open the linked document. This attribute is used in the <a> element.(W-1-8)
Example:

(W-1-8)

Activity:
Find 5 more attributes that I have not mentioned above, and list them down in the comment section below with their functionality. 

Conclusion

HTML attributes are an important part of HTML syntax that allows you to add additional information and functionality to HTML elements. By using attributes, you can create more dynamic and interactive web pages that are easier to style and navigate.


Post a Comment

Previous Post Next Post
LightBlog
LightBlog