Make Money Online HTML PHP JAVASCRIPT HTML Tutorial for Beginners Tamil – 10 – HTML CLASS & ID ATTRIBUTES

HTML Tutorial for Beginners Tamil – 10 – HTML CLASS & ID ATTRIBUTES

HTML Tutorial for Beginners Tamil – 10 – HTML CLASS & ID ATTRIBUTES post thumbnail image


HTML CLASS & ID ATTRIBUTES

In this tutorial, we will take a look at the HTML class and id attributes. These attributes are used to specify the class or id of an element, respectively.

The class attribute is used to specify one or more class names for an element. The class name(s) can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name(s).

The id attribute is used to specify a unique id for an element. The id can be used by CSS and JavaScript to perform certain tasks for the element with the specified id.

Class Attribute

The class attribute is used to specify one or more class names for an element. The class name(s) can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name(s).

To specify multiple class names for an element, you can separate the class names with spaces. For example:

This is a paragraph.

This is another paragraph.

This is yet another paragraph.

In the above example, we have three paragraphs each with a different combination of two classes: “class1” and “class2”. We can then use CSS or JavaScript to perform different actions on each paragraph based on which classes it has. For example, we could use CSS to make all paragraphs with the “class1” class have a red color, like so: p.class1 { color: red; } In this way, we can style elements based on which classes they have. This can be very useful when creating CSS layouts as it allows us to group elements together that should have similar styles. Now let’s take a look at how we can use the id attribute… ID Attribute The id attribute is used to specify a unique id for an element. The value of the id attribute must be unique within the document. That means that there can only be one element with a given id value in any given document. The id attribute can be used by CSS and JavaScript to perform certain tasks for elements with the specified id . For example, we could use CSS to make all elements with an id of “my_id” have a red color, like so: #my_id { color: red; } In this way, we can style or manipulate elements based on their id . This can be very useful when we want to specifically target a single element (or group of elements) with our CSS or JavaScript code. Conclusion That’s all there is to know about using the HTML class and id attributes! In the next tutorial, we’ll learn about some more advanced HTML attributes that will come in handy when creating websites.

Related Post