Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applying different style to specific input button

Tags:

html

css

check out this JSFiddle
I want to apply different style to second button. I guess there is just a different sytax. Help.

<input type="button">
<input type="button" class="button2">

I dont want to use id, beacause it's to be used for some other purpose.

like image 880
SurajS Avatar asked Jan 16 '15 12:01

SurajS


People also ask

How do you apply inline style?

An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.


2 Answers

Specificity is the means by which a browser decides which property values are the most relevant to an element and gets to be applied. Specificity is only based on the matching rules which are composed of selectors of different sorts.

You can specificity the css selector using 'has' class add apply the rule to input button elements with class .button2:

input[type="button"] {
  width: 500px;
  background: red;
}
[type='button'].button2 {
  width: 100px;
  background: black;
}
<input type="button">

<input type="button" class="button2">

Also take a look Specificity.

like image 148
Alex Char Avatar answered Oct 01 '22 19:10

Alex Char


<input type="button">

<input type="button" class="button2">


input[type="button"]{
    width: 500px;
    background: red;
}
input[type="button"].button2{
     width: 100px;
     background: black;

 }

Fiddle: http://jsfiddle.net/0dyk2n3b/1/

like image 32
Gustaf Gunér Avatar answered Oct 01 '22 20:10

Gustaf Gunér