HTML Class: Learn All About HTML Class

Class in HTML is a reference which you use to apply some CSS properties to HTML elements. With class, you can define the style for class with a dot operator, and then you can just add the class whenever you want to apply that style. In this tutorial, you will learn about HTML Class and its application.

In this "html class" tutorial will explore the following topics:

  • Class attribute In HTML
  • Multiple Classes
  • Same class with different tag 

Class Attribute in HTML

In HTML, you can add a “class” as an attribute to an element to indicate that it should take on the styling attributes of the class. 

HTML_Class_1

Here's How to Land a Top Software Developer Job

Full Stack Developer - MERN StackExplore Program
Here's How to Land a Top Software Developer Job

Here you defined the class name with ‘heading’. You then used this class name to style the element. 

HTML_Class_2

Multiple Classes

You can also use multiple classes in the same element. Here, a space must separate the class name.

HTML_Class_3

All the three headers have the class name “country”, but BELGIUM also has the class name “middle”, which makes the text center-aligned.

HTML_Class_4

Become a Certified UI UX Expert in Just 5 Months!

UMass Amherst UI UX BootcampExplore Program
Become a Certified UI UX Expert in Just 5 Months!

Same Class With Different Tag

Different HTML tags can use the same class name, hence incorporating the same style. 

/HTML_Class_5

Here, as you can see, you have the same class name ‘country’ on different tags. Both the tags share similar styles.

HTML_Class_6

Advance your career as a MEAN stack developer with the Full Stack Web Developer - MEAN Stack Master's Program. Enroll now!

That was al about HTML Class.

Conclusion

So with this, you have come to an end of this HTML Class  tutorial. You learned how you can use the classes on your HTML tags to style them better in CSS by specifying the individual class name.

If you are looking for a comprehensive course in Full-Stack Development, you should definitely check our Post Graduate Program in Full Stack Web Development in collaboration with Caltech CTME. This course offers applied industry-ready training in all the skills, tools, and languages you need to learn to become a successful full-stack developer.

If you have any questions regarding this ‘Classes in HTML’ tutorial, do share them in the comment section. Our subject matter expert will respond to your queries. Happy learning!

About the Author

SimplilearnSimplilearn

Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.