CSS List-Style-Position Bullet Alignment in Safari Web Inspector
In this article
To inspect and control CSS list-style-position bullet alignment in Safari's Web Inspector, open the Elements tab, select the <ul> or <ol> element, and look at the Styles pane—you'll see the computed value and can toggle list-style-position: inside or outside directly. The key is understanding that outside (the default) places bullets outside the content box, which can cause misalignment with padding or borders, while inside shifts bullets into the content flow.
Background: How list-style-position Works
The list-style-position property controls whether the marker (bullet or number) appears inside or outside the principal block box of the list item. With outside, the marker is placed to the left of the content, but it is not part of the content flow—it's positioned in the margin area. With inside, the marker becomes the first inline box within the list item, so it wraps with the text and is affected by padding.
In Safari (and other WebKit browsers), the default is outside. This is why you often see bullets hanging to the left of the text, aligned with the left edge of the list's padding box. If you set a left padding on the <ul>, the bullets will shift right along with the padding, but the text will align differently depending on the position value.
Using Safari Web Inspector to Inspect Bullet Alignment
To see exactly how bullets are aligned, follow these steps:
- Open Safari and navigate to the page with the list you want to inspect.
- Right-click the list and choose "Inspect Element" (or press Cmd+Option+I to open Web Inspector).
- In the Elements tab, select the
<ul>or<ol>element. The Styles pane on the right shows all applied CSS rules. - Look for
list-style-positionin the Styles pane. If it's not there, it's using the defaultoutside. - To see the computed value, click the "Computed" tab (or filter) and search for "list-style-position".
The Web Inspector also visually highlights the box model. When you select the list item (<li>), you can see the content, padding, border, and margin areas. The bullet's position relative to these boxes helps you understand the alignment.
Common Problems and Misconceptions
One common issue is that with list-style-position: outside, the bullet may appear cut off or misaligned if the <ul> has a background or border. This happens because the bullet is drawn in the margin area, which is outside the element's background. To fix it, you might add left padding to the <ul> to push the content, but that also moves the bullet.
Another misconception is that list-style-position affects vertical alignment of the bullet relative to the text. In reality, the vertical alignment is determined by the font metrics and line-height; the property only controls horizontal placement. If bullets appear too high or low, it's usually due to line-height or font-size, not list-style-position.
Also, note that Safari (like other browsers) may have subtle differences in how it renders bullets for <ul> vs <ol>. Ordered list numbers are aligned differently than unordered bullets, especially with multi-digit numbers.
How to Control Bullet Alignment with CSS
To precisely control bullet alignment, you have several options beyond just toggling inside or outside:
- Use
list-style-position: insideto keep bullets within the content box, so they align with text padding. - Adjust padding on the
<ul>to shift both bullets and text. Foroutside, adding left padding moves the entire list right, but the bullets stay at the left edge of the padding. - Use
list-style-typeto change the marker shape, but note that alignment is independent of marker type. - Use pseudo-elements (e.g.,
::marker) to style the marker individually, including its vertical alignment, though support varies.
For example, to make bullets hang outside a bordered box, you might do:
ul {
list-style-position: outside;
margin-left: 1.5em; /* space for bullets */
padding-left: 0;
}
This keeps bullets in the margin area while ensuring they aren't clipped by a background.
Comparing Safari with Other Browsers
Safari's rendering of list-style-position is generally consistent with Chrome and Firefox, but there are minor differences. For instance, Safari may apply default margins to <ul> and <ol> (typically margin: 1em 0 1em 40px), which affects where bullets appear. Chrome uses similar defaults, but Firefox may differ slightly in how it handles the marker box.
When using Web Inspector, you can compare computed styles across browsers by opening the same page in each and inspecting the same element. This helps identify if a misalignment is due to browser-specific defaults or your own CSS.
Advanced Techniques: Using ::marker and Custom Bullets
For finer control, you can use the ::marker pseudo-element to style the bullet itself. This allows you to change its color, size, and even vertical alignment using properties like vertical-align (though not all properties are supported). For example:
li::marker {
color: red;
font-size: 1.2em;
vertical-align: middle;
}
However, support for vertical-align on ::marker is limited; Safari supports it, but Chrome may not. If you need consistent cross-browser alignment, consider using a background image or pseudo-element on the <li> instead of the native marker.
Another approach is to hide the native marker and use a custom bullet with list-style: none and a li::before pseudo-element. This gives you complete control over alignment:
ul {
list-style: none;
padding-left: 0;
}
li::before {
content: "•";
margin-right: 0.5em;
vertical-align: middle;
}
This method is widely supported and allows precise positioning.
Frequently Asked Questions
Why do my bullets appear cut off in Safari?
This usually happens when the <ul> has a background or border and list-style-position: outside is set. The bullet is drawn in the margin area, outside the element's background, so it may be clipped. Solution: add left padding to the <ul> to create space for the bullet, or switch to inside.
How do I align bullet text with the bullet in Safari?
With list-style-position: inside, the bullet is part of the text flow, so it aligns with the first line. With outside, the bullet is separate; to align text with the bullet, you need to ensure the list's padding and margin are set appropriately. A common pattern is to set padding-left: 1.5em on the <ul> and margin-left: 0.
Does Safari support list-style-position on all elements?
Yes, Safari supports list-style-position on elements with display: list-item, which includes <li> elements and any element with display: list-item. It also works on <ul> and <ol> because they inherit to their list items.
Why does my ordered list number alignment differ from unordered bullets?
Ordered list numbers are right-aligned within their marker box by default, so multi-digit numbers align on the right. Unordered bullets are typically centered. This is a browser default and not directly controlled by list-style-position. You can change it with the list-style-type property or by using custom markers.
Can I inspect the bullet's computed position in Web Inspector?
Yes, select the <li> element and look at the Computed tab. You'll see the box model values, but the bullet position is not explicitly shown. To visualize it, you can toggle the "Show rulers" or use the "Layer" view, but the easiest way is to temporarily add a background to the <ul> to see where the bullet sits relative to the padding box.
Is there a way to make bullets align perfectly across all browsers?
For perfect cross-browser alignment, it's best to use a custom bullet with list-style: none and a pseudo-element. This gives you full control over positioning and avoids browser-specific default spacing. Use a consistent margin or padding value, and test in Safari, Chrome, and Firefox.