0

Unorder list can't background color change

<style> ul{ background-color:blue; } li{ float:left; } </style>

26th Feb 2022, 10:11 AM
Chalacho
14 ответов
+ 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
26th Feb 2022, 10:21 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 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>
26th Feb 2022, 10:31 AM
Chalacho
+ 2
You want the <li> to appear in a single line?
26th Feb 2022, 10:50 AM
Ipang
+ 1
The float: left; rule seems to be the source of problem. But I don't have an explanation.
26th Feb 2022, 10:20 AM
Ipang
+ 1
Hi Chalacho, Sorry I didn't understand, what did you mean "list float left"?
26th Feb 2022, 10:42 AM
Ipang
+ 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>
26th Feb 2022, 11:03 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 1
Muhammad awesome thanks; but why can't work with "float"
26th Feb 2022, 11:11 AM
Chalacho
+ 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
26th Feb 2022, 11:18 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
0
Remove float: left; from 'li' selector in the style definition.
26th Feb 2022, 10:34 AM
Ipang
0
Hi Ipang at that time how my list float left
26th Feb 2022, 10:40 AM
Chalacho
0
Ipang See my code with float output: .pene.book Without float .pene . book So output of list line and block
26th Feb 2022, 10:49 AM
Chalacho
0
if you wants to give color to in ul you have to make nav bar for tha
27th Feb 2022, 9:40 AM
Asim Shaikh
Asim Shaikh - avatar
0
You can try with this selector... ul li{ background-color: blue; }
27th Feb 2022, 6:18 PM
Asiya Akther
Asiya Akther - avatar
0
You have to add id or class.
27th Feb 2022, 7:11 PM
Happy Coder
Happy Coder - avatar