Contact Us || Privacy Policy || About Us |
|
HTML Class⟼. The class attribute is often used in CSS and JavaScript for some tasks. When you can use the class in CSS , you can use Dot (.) character, followed by the name of the class for selecting elements. class attribute can be defined within <style> tag or use in separate file . See in Example:Output:- This is first heading use of class elementsSee in Example 2:Output:- The class AttributeUse CSS to style elements with the class name "city": IndiaIndia is the capital of New Delhi. IndiaIndia is the Grate Country. Class Attribute Use in JavaScriptWhen class name can be used in JavaScript then use getElementsByClassName() method to perform certain tasks for specific elements. See in Example :OutPut:-Click the button to hide all elements with class name "city": CHINAChina has the largest population in the world. INDIAIndia has the second largest population in the world. UNITED STATESUnited States has the third largest population in the world.
Next TopicHTML ID
|