Set style for elements with a particular attribute

To define style on elements with a particular attribute/property you need the following syntax:

[attribute1], [attribute2], ...
{
/*Define style here*/
}

Example:

<html>
 <head>
  <style>
   [tabIndex], [id]/*applies to the elements with any of tabIndex attribute and id attribute specified*/
   {
    border:10px solid green;
   }
  </style>
 </head>
 <body>
  <div tabIndex=1>abc</div>
  <div id='div2'>def</div>
  <span tabIndex=3>ghi</span>
  <div>jkl</div>
  <div tabIndex=2>mno</div>
 </body>
</html>

Check DEMO here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s