0 0
Read Time:1 Minute, 7 Second
  • The element selector selects HTML elements based on the element name.
  • The id selector uses the id attribute of an HTML element to select a specific element.
  • The class selector selects HTML elements with a specific class attribute.
  • You can also specify that only specific HTML elements should be affected by a class.
  • The universal selector (*) selects all HTML elements on the page.
  • The grouping selector selects all the HTML elements with the same style definitions.
<!DOCTYPE html>
<html>
<head>
<style>
/*  universal selector  */

* {
  text-align: center;
  color: blue;
}

/*  id  */

#para1 {
  text-align: center;
  color: red;
}

/*  class  */

.center {
  text-align: center;
  color: red;
}



p.cg {
  text-align: center;
  color: green;
}

/*  grouping  */

h3, h2, p.cp {
  text-align: center;
  color: purple;
}
</style>
</head>
<body>

<p id="para1">Hello World!</p>
<p>HELLO INDIA</p>

<h1 class="center">Hi, Welcome to TopperG heading</h1>

<p class="cg">Hi, Welcome to TopperG paragraph.</p>

<p class="center">Hi, Welcome to TopperG heading</p>

<h2>Hi, Welcome to TopperG heading</h2>

<p class="cp">Hi, Welcome to TopperG paragraph.</p>


</body>
</html>

See also  Academic Electives Class 11th and 12th CBSE Curriculum 2022-23
See also  COMMENTS IN CSS ( CASCADING STYLE SHEET )
Happy
Happy
%
Sad
Sad
%
Excited
Excited
%
Sleepy
Sleepy
%
Angry
Angry
%
Surprise
Surprise
%