Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply css to button element with certain class

Tags:

css

bluebutton.css

.btnBlue button{
Styles go here
}

.btnBlue button::-moz-focus-inner{
Styles go here
}

.btnBlue button:hover,button:focus{
styles go here
}

.btnBlue button:active{
Styles go here
}

index.html

<!DOCTYPE html>
<html>
<head>
<title>Css buttons</title>
<link type='text/css' href='css/bluebutton.css' rel='stylesheet' media='screen' />
</head>
<body>
<button type="submit" class="btnBlue">Okay</button>
</div>
</body>
</html>

This does not seem to work. I know it works if i try to do it without the .btnBlue but i want to create different button styles. So like i can define for each button what style to use.

like image 439
Keverw Avatar asked Apr 01 '11 10:04

Keverw


People also ask

How do I apply a CSS to a specific class?

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.

Can you make a class selector particular to an element type?

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

Can buttons have classes?

Classes (i.e. classnames) are used for styling the button element. Multiple classnames are separated by a space. JavaScript uses classes to access elements by classname. Tip: class is a global attribute that can be applied to any HTML element.


1 Answers

Think you need to change the stylesheet declarations here to:

button.btnBlue{ Styles go here }

button::-moz-focus-inner.btnBlue{ Styles go here }

button:hover.btnBlue,button:focus.btnBlue{ styles go here }

button:active.btnBlue{ Styles go here }

like image 176
simnom Avatar answered Oct 20 '22 23:10

simnom