You mean two classes? "Chain" the selectors (no spaces between them):
.class1.class2 {
/* style here */
}
This selects all elements with class1 that also have class2.
In your case:
li.left.ui-class-selector {
}
Official documentation : CSS2 class selectors.
As akamike points out a problem with this method in Internet Explorer 6 you might want to read this: Use double classes in IE6 CSS?
Answer from Felix Kling on Stack OverflowSelect multiple elements with the same class. [help]
Correct usage of classes and other selectors
What is the difference between 2 classes that has whitespace between and the ones that doesn't have.
Is adding many classes to an element good practice?
Videos
You mean two classes? "Chain" the selectors (no spaces between them):
.class1.class2 {
/* style here */
}
This selects all elements with class1 that also have class2.
In your case:
li.left.ui-class-selector {
}
Official documentation : CSS2 class selectors.
As akamike points out a problem with this method in Internet Explorer 6 you might want to read this: Use double classes in IE6 CSS?
Chain selectors are not limited just to classes, you can do it for both classes and ids.
Classes
.classA.classB {
/*style here*/
}
Class & Id
.classA#idB {
/*style here*/
}
Id & Id
#idA#idB {
/*style here*/
}
All good current browsers support this except IE 6, it selects based on the last selector in the list. So ".classA.classB" will select based on just ".classB".
For your case
li.left.ui-class-selector {
/*style here*/
}
or
.left.ui-class-selector {
/*style here*/
}
I have this ancient project that I take a look from time to time. I'm not a webdev, I can move my way with php and backend stuff, but frontend is a little bit daunting to me.
I was checking the mainpage with webdev tools and found that my "plain" styles were being overridden by an override that is only supposed to kick-in for a certain class.
These are my original styles
h1,h2,h3,h4,h5,h6,p,li {
background-color: blue;
}But let's say I want to change the background-color when them belong to a certain class
.newclass h1,h2,h3,h4,h5,h6,p,li {
background-color: yellow;
}And this is the markup
<h1>Hello</h1> <h2>World</h3> <p>I'm Here!</p> <p>This should be blue</p> <p class="newclass">and this yellow</p> <h1 class="newclass">still can't</h1>
I'm expecting for lines 5 and 6 to have a yelllow background and the all the others a blue background.
But 1 and 6 are blue and 2 to 5 are yellow.
My thought was that space is an AND and comma is an OR and supposedly I'm asking for all the comma separated elements to gain the new attribute IF AND ONLY IF them match the class before the space.
What am I doing wrong?
I tried to google it but couldn't figure it out.
Here is a code pen with the same example
I started to learn CSS about two days ago. However, I am still a little confused on the TON of different selectors that still yield the same result even with different methods. I am aware that classes can be named anything? If I remember correctly.
(The provided screenshots show my code. The first two are mine. The last two are the Odin Project's.)
I just want to know from the more seasoned veterans here how my coding could be better and/or more efficient in the future. And it would help a lot if some helpful links/tips were dropped to better understand CSS and its varying usage of selectors, properties, and values. Thank you