Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use particular word from class in css?

i have some '<a> <i> <label>' in my page like below with the class

<a class="icon-home"></a>
<label class="icon-pencil"></label>
<i class="icon-display"></i>

i need to create css with margin-right:10px when class start with "icon-"

some thing like below:

<style>
.icon-* {margin-right:10px}
</style>
like image 862
user475464 Avatar asked Jun 14 '13 11:06

user475464


People also ask

How can we select an element with a specific class in CSS?

class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.

Is it possible to make a class selector for a particular element if so how?

You can create a selector that will target specific elements with the class applied.

How do I target my CSS ID?

To use an ID selector in CSS, you simply write a hashtag (#) followed by the ID of the element. Then put the style properties you want to apply to the element in brackets.


1 Answers

Try this:

[class^="icon-"], [class*=" icon-"] {
    margin-right: 10px;
}
like image 124
Guilherme Oderdenge Avatar answered Oct 17 '22 20:10

Guilherme Oderdenge