What are the steps to create a custom list style that suits my needs?

I created an HTML list and wanted to use ballot boxes with check marks instead of default bullets, so I incorporated some CSS:

ul {
  list-style: none;
}
li::before {
  content: "\2611";
}
<ul>
  <li>Long text</li>
  <li>Long text</li>
  <li>Long long text</li>
</ul>

Everything appeared to be perfect at first, but as soon as the text in the <li> elements spanned two lines or more, the second line started without any space.

In simpler terms, the first character on a new line should align under the bullet point, not under the first letter of the previous line.

I'm stumped as to how to address this issue.

Answer №1

To ensure proper alignment of custom content, you have the flexibility to adjust li text-indents and padding as needed.

ul { list-style: none; }

li { text-indent: -20px; margin: 10px 0;}

li::before { content: "\2611"; color: #a00; padding-right: 5px; }
<ul>
<li>Long text</li>
<li>Long text</li>
<li>Long long text Long long text Long long text Long long text Long long text Long long text </li>
<li>Long text</li>
<li>Long long text Long long text Long long text Long long text Long long text Long long text </li>
<li>Long text</li>
</ul>

Answer №2

Want to spruce up your list style? Consider adding a custom image for a unique touch and to solve any spacing problems.

ul {
  list-style-image: url('customimage.gif');
}

For additional details, check out this link.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a background color without using the <canvas id> element can be achieved by utilizing CSS properties such as

As a novice in the world of HTML and CSS, I find myself working on creating my website using HTML. Upon inspecting my site, I notice that the default background color is white. Despite trying to change it by using #canvas { background-color: black; } in ...

What is the best way to ensure consistent spacing between columns in a Bootstrap 3 grid layout, similar to the spacing on the left and right sides?

Is there a way to achieve equal spacing between all blocks in a row, similar to the left and right padding that Bootstrap automatically applies? Currently, Bootstrap adds padding to all columns on both sides, but does not render extra spacing on the left s ...

Activate the function within the same class only for the selected item

Hello there, I'm struggling to grasp how to make this particular functionality work. Basically, I have 8 divs, each containing an image used as a button with the same class (tm-img), and hidden divs with additional information. My goal is to initiall ...

Utilizing the Bootstrap grid system for arranging inline elements

When it comes to having a heading tag with a secondary subtitle like this: https://i.sstatic.net/p9SKW.png <h3> Fancy display heading <small class="text-muted">With faded secondary text</small> </h3> Is there a way to ...

Take away the attention from the span element

I have been experimenting with the following jsfiddle and attempted various methods suggested in this Stack Overflow thread, but I am struggling to remove the focus from the "feedback" span after clicking on the cancel button in jQuery confirm dialog. Her ...

Is it possible to rotate a group within an SVG without altering the orientation of the gradient fill it contains?

In my search on SO, I came across a lot of information about rotating gradients. However, my issue is the opposite. I have an icon created from multiple paths that I want to fill with a vertical gradient. I have successfully done this and it works well. ...

Choose tag using position in a sequence

I am working on updating the label text "E-mail" to say "User Name" in this HTML markup. The only tool I have access to for this task is jQuery. <div class="foo" style="border:1px solid #444"> <span class="field-with-fancyplaceholde ...

Leverage htaccess functionality to modify website configurations without altering the URL

I currently have the following htaccess configuration: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ dl.php?id=/$1 [QSA,L] </IfModule> It works perfectly fine. However, I am facing a problem with my site URLs and images ...

Is there a way to insert a label directly following a dropdown menu within the same table cell?

My goal is to include drop-down lists in a web page, so I decided to create a table structure using JavaScript. Firstly, I used the document.createElement() method to generate a table, table body, rows, and cells. Then, I proceeded to create select element ...

Tips on displaying a div using javascript

I have a minor issue that I need assistance with. I am working on a PHP project where I need to dynamically generate product information on a webpage. Specifically, when a user clicks on the "Quick Look" option, a pop-up window should appear displaying rel ...

Merging of rows is being witnessed in Boostrap 3/ASP.NET

I recently encountered a perplexing issue with the layout of my website. I had a jumbotron placed within a bootstrap row in a masterpage, followed by a contentplaceholder. When I added a row inside the contentplaceholder on a separate page, it should have ...

When making cross-origin requests, characters inside the <style> tags are transformed into Unicode HTML Entities

I am currently working on a NextJS application with react-jss integration. Within my CSS, I have a specific rule targeting '& .working[style="display: block;"] ': {...} Everything works perfectly when accessing the page from the s ...

Alignment of the table with a fixed header and scrollable body

Currently, I am experiencing an issue with aligning a table. My aim is to have a fixed header and a scrollable body for the table. To do this, I have aligned the table header and body using: display: table-header-group For the table body, I have applied ...

CSS - Divs failing to center using 'Auto: 0 Margin'

Attempting to design a menu bar using CSS, where the main buttons (blue divs) need to be centered within the navigation bar (orange divs) with equal spacing between each button. Despite trying margin: 0 auto, the alignment is not working as expected. Bel ...

We need to display JSON data from a URL onto an HTML page within a table format

Could someone assist me with fetching JSON data from a URL Link on Amazon AWS and displaying it in an HTML table? I am a novice at this, so please explain it easily. Below you can see the HTML code, JS code, and sample information that I would like to ex ...

What is the correct timing for implementing a JavaScript delay to activate CSS styling?

Let's say I have some CSS like #joe { transition: opacity 500ms; opacity: 0; } Next, I include JavaScript that triggers the addition of a div and then animates the opacity to = 1 when you click the page. document.body.onclick = function () { var j ...

Multi selection dropdown feature in Angular failing to populate the options

I am working on a small Angular controller that manages a dropdown menu, with the second dropdown menu populating based on the selection made in the first one. Despite my best efforts, I can't seem to populate the dropdown menus with any content from ...

Can we showcase additional information in a horizontal layout?

In the process of creating a one-page website, I plan to include a Portfolio section that will showcase various projects using 4 thumbnails. Each thumbnail will display HTML content through fancybox. I am considering incorporating two arrow buttons on eac ...

Tips for directing attention to a div element

Need some help here! I'm just starting out with JS and jQuery, so please be gentle. Is it possible to set focus on a div element? I am looking to trigger events when the div is clicked or focused, as well as when clicking outside of the div. Here&apos ...

Shifting and positioning the card to the center in a React application

I am currently constructing a React page to display prices. To achieve this, I have created a Card element where all the data will be placed and reused. Here is how it appears at the moment: https://i.stack.imgur.com/iOroS.png Please disregard the red b ...