Hi i want to apply css for first 2 elements (one,two) that are adjacent to first element.
For first 2 li elements inside ul p try:
.one ul li:nth-child(-n+3){
// your style
}
See on jsfiddle
And as other mates mentioned: you have invalid markup.
If you removed p element, try:
.one ul li:nth-child(-n+2){
// your style
}
See on jsfiddle
Update: My suggestion is to use another ul instead of p: So you have valid markup and same result:
HTML
- 0
-
- One
- Two
- 3
-
- Four
- Five
CSS:
.one ul {
padding: 0;
list-style-type: none;
}
.one ul ul li:nth-child(-n+2){
// your style
}
Updated jsfiddle
Note: As your last comment, If you have only 2 special li element, Why not define a class name simply... Do it simple
ul li.bold {
// your style
}