• SQL Tutorial
  • jQuery
  • Spring
  • JSP
  • Java IO
  • Core Java
  • RubyonRails
  • PHP
  • Struts

  • <

    HTML Classes

    Class is define one or more class names for an HTML element.The class name can be used by CSS and JavaScript to do some tasks for HTML elements.

    HTML Classes Example

    <!DOCTYPE html>
    .name {
        background-color: tomato;
        color: white;
    <h2 class="name">sunil kumar</h2>
    <h2 class="name">rahul yadav</h2>

    HTML Classes in Javascript

    <!DOCTYPE html>
    <p>Click the button hide to hide all elements with JavaScript:</p>
    <button onclick="hide()">Hide</button>
    <h2 class="name">arun</h2>
    <h2 class="name">raju</h2>
    <h2 class="name">sunil</h2>
    function hide() {
      var a = document.getElementsByClassName("name");
      for (var i = 0; i < x.length; i++) {
        a[i].style.display = "none";

    © copyright 2017-2021 Completedone pvt ltd.