ShellRox ShellRox - 1 year ago 67
CSS Question

How can i apply css stylesheet to single specific element?

I am new to web development, I have tried css stylesheet with simple HTML element and it worked well, when i specified element name:

label {
color: green;

this would be applied to all label tags, but is there any way to apply stylesheet to single element? For example: There are 2 labels, one is green and second is blue, How can this be achieved?

Answer Source

There's lots of ways to accomplish this. There's lots of css selectors like ID, classes... See css selectors reference

Best way to achieve what you want is to use classss. See classes

.red {
      color: red;
.blue {
      color: blue;
<label class="blue">
    I'm blue
<label class="red">
  I'm red


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download