0
Unorder list can't background color change
<style> ul{ background-color:blue; } li{ float:left; } </style>
14 Answers
+ 4
Make sure that you have only one an unordered list in your code because if you have more than one and you give each of them a specific style using the tag name then the last style will replace all previous styles for all unordered lists, if not try to but id to your list and try to style it using id
Note : Make sure you but style tag in head tag and the best is to put your code here so we can determine where the problem and help u
+ 2
Can't not change background color see my sample code
<html>
<head><title></title>
<style>
ul{
background-color:blue;
}
li{
float:left;
}
</style>
</head>
<body>
<ul>
<li>pene</li>
<li>book</li>
</ul>
</body>
</html>
+ 2
You want the <li> to appear in a single line?
+ 1
The float: left; rule seems to be the source of problem. But I don't have an explanation.
+ 1
Hi Chalacho,
Sorry I didn't understand, what did you mean "list float left"?
+ 1
Chalacho
If u wanna make a block element like li element appears as an inline element , you should use display attribute
So your code will be
<html>
<head><title></title>
<style>
ul{
background-color:blue;
}
li{
display: inline-block;
}
</style>
</head>
<body>
<ul>
<li>pene</li>
<li>book</li>
</ul>
</body>
</html>
+ 1
Muhammad awesome thanks; but why can't work with "float"
+ 1
float used in other purpose opposite of float
I advise u to search 🔍🔎 about float attribute on Google you will find more examples which will help you to understand it
0
Remove float: left; from 'li' selector in the style definition.
0
Hi Ipang at that time how my list float left
0
Ipang See my code
with float output: .pene.book
Without float .pene
. book
So output of list line and block
0
if you wants to give color to in ul you have to make nav bar for tha
0
You can try with this selector...
ul li{
background-color: blue;
}
0
You have to add id or class.