Select element that has a class that starts with a string - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:class

Description

Select element that has a class that starts with a string

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.element {<!--from w w w. ja v a2s . c o m-->
   background-color:Chartreuse;
   height:51px;
   margin:11px;
   width:51px;
}

.element[class^='icon-'],
.element[class*=' icon-'] {
   background-color:yellow;
}
</style> 
 </head> 
 <body> 
  <div class="element"></div> 
  <div class="element icon-one"></div> 
  <div class="icon-two element"></div>  
 </body>
</html>

Related Tutorials