only-of-type Selector

only-of-type Selector
CSS only-of-type Selector reference
The CSS only-of-type structural pseudo-class selector ( X:only-of-type ) is used to target and style an element if it is the only element of its type in a specified parent element.
CSS CODE EXAMPLE
<!DOCTYPE html>
<style type="text/css">
div p:only-of-type {
    background-color: #FCA7E7;
}
</style>
<div>
  <p>content...</p>
  <span>content...</span>
</div>
<hr />
<div>
  <p>content...</p>
  <p>content...</p>
</div>
 
content...
content...

content...
content...

Related Posts :

  • border border CSS border Property The CSS border property is shorthand CSS for specifying u… Read More...
  • display display CSS display Property The CSS display property is used to alter the default di… Read More...
  • border-X border-X CSS border-X Property The CSS border-left, border-top, border-right&nb… Read More...
  • color color CSS color Property The CSS color property is used to specify foreground color … Read More...
  • clear clear CSS clear Property The CSS clear property is used to clear space for an elemen… Read More...

0 Response to "only-of-type Selector"

Post a Comment