Specificity means that more specific selectors are given priority over less specific selectors : Selector priority « Style Basics « HTML / CSS






Specificity means that more specific selectors are given priority over less specific selectors

 

<html>
<head>
<title>Specificity</title>
<style type="text/css">
body {
  background-color: red;
  font-size: 1.3em;
  color: white;
  font-family: Arial, sans-serif;
}

p {
  color: navy;
}

p b {
  color: white;
}

b#cyan {
  color: cyan;
}
</style>
</head>
<body>
<h1>Specificity:</h1>
<p><i><b id="cyan">Specificity</b></i> means that more <b>&quot;specific&quot;</b>
selectors are given priority over less specific selectors.</p>
</body>
</html>

 








Related examples in the same category

1.Selectors choose the element to apply formatting to
2.Six selector groups listed from highest to lowest priority:
3.Style is overwritable
4.Cascade Order
5.select elements by type, class, and/or ID
6.Specificity, !important
7.!important has higher priority
8.Latter one overwrite the former one
9.the id selector is more specific than the element selector
10.Some properties in CSS are inherited to children elements