- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to transform a basic list into a "list group" with CSS?
To create a basic list, use the <ul> element. Use the <li> to place the list items in the <ul>. To form it a list group, use the CSS styled. Let us see how to transform a basic list into a list group with HTML and CSS. First, we will create an unordered list.
Create an unordered list
The <ul> element is used to create an unordered list. The list items are set using the <li> elements −
<ul> <li>Lion</li> <li>Tiger</li> <li>Leopard</li> <li>Cheetah</li> <li>Jaguar</li> <li>Cat</li> <li>Dog</li> </ul>
Remove the bullets
To remove the bullets from the unordered list, use the list-style-type property with the value none. The padding and margins are also set to 0 −
ul { list-style-type: none; padding: 0; margin: 0; }
Style the unordered list
Set a border for the unordered list to make it look like a list group. The border is set using the border property −
ul li { border: 1px solid rgb(0, 0, 0); background-color: rgb(246,246,246);; padding: 12px; font-size: 18px; }
Example
To transform a basic list into a “list group” with CSS, the code is as follows −
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } * { box-sizing: border-box; } ul { list-style-type: none; padding: 0; margin: 0; } ul li { border: 1px solid rgb(0, 0, 0); background-color: rgb(246,246,246); padding: 12px; font-size: 18px; } </style> </head> <body> <h1>List Group Example</h1> <ul> <li>Lion</li> <li>Tiger</li> <li>Leopard</li> <li>Cheetah</li> <li>Jaguar</li> <li>Cat</li> <li>Dog</li> </ul> </body> </html>
Advertisements