Web Design Blog
Popular Posts
- Fonts on the web and a list of web safe fonts
- CSS Hack:Getting Safari to behave
- Top 10 search engine optimization techniques
- Test IE5 or IE6 on your PC with IE7 installed
- Top 10 job boards for freelance web designers
- Creating a photo gallery in CSS without tables
- CSS Trick: Target only IE with an if statement
- Open source Dreamweaver alternatives
- 8 job boards, for freelance web designers, that don't suck
- CSS fix for the double margin float bug in IE6
Categories
Using multiple CSS styles on a single element
Posted on Monday, November 5th, 2007 under CSS by Dustin Brewer.I have been asked questions recently about using different sets of styles on elements and thought I would briefly touch on the subject to explain a little further. Have you ever wanted to use styleA and styleB on the same div? Well with classes you can, you can easily specify multiple classes on what div or any element that you want without any trouble at all.This isn’t explicitly stated in some help sites and can be easily overlooked because it is not often that you can do this kind of thing within HTML and CSS. You will see below what I mean if it is still unclear what I am talking about.
<div class="styleA styleB">
</div>
Nothing particularly fancy but can come in very handy if you have several different objects that are only styled slightly different but you want to write less CSS. You can use as many classes on any type of element as you need. There isn’t a limitation of any kind on such things.


whew awesome- additional information again. great job.
Thanks
Nice, easy CSS article. Love the site!
I don’t think you mentioned that you can also apply an id to those elements as well as multiple CSS classes.
Great css 101 article, definitely something for beginners to be aware of— it can save a ton of time!