Solved

Simple referencing a class in css

Posted on 2011-03-24
8
267 Views
Last Modified: 2012-08-13
I have a span like this:

<span class="chkbox deselected">

</span>

is the below code is how you reference the span in CSS?

span.chkbox.deselected{

float:left;

}
0
Comment
Question by:PagodNaUtak
  • 4
  • 3
8 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 35204975
since deselected and chkbox are two different classes
span.chkbox
{
}

span.deselected
{
}

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35204981
if you want to give them the same style (or a common style), then
span.chkbox, span.deselected
{
}
0
 
LVL 2

Expert Comment

by:JanEnEm
ID: 35205071
Although I believe there is no restriction as to use spaces in a className, in this situation I would avoid using spaces.
Hence leave the spaces out and call the class "checkboxSelected"

The CSS selector would then be
 span.checkboxSelected
{
}
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 8

Author Comment

by:PagodNaUtak
ID: 35205179
I want to apply a css to a div having the class checkbox and deselected
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35205196
did you tried my solution?
0
 
LVL 2

Expert Comment

by:JanEnEm
ID: 35205285
@qurvinder: Are you saying you want two class to one div/span?

Or do you want a class "selected'  and a class "deselected"?
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 500 total points
ID: 35205314
yes.
Since in the original question, he specified two classes, and also clarified that he wants to apply the style to a div with two classes.

You can always specify multiple classes for any element, see the specification here
http://www.w3.org/TR/html401/struct/global.html#h-7.5.2

0
 
LVL 2

Expert Comment

by:JanEnEm
ID: 35205620
Communications was too async. I agree with the comments Qurvinder made.
His CSS suggestions are OK!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question