Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS right aligned list

Tags:

html

css

How should I align the list to the right? The text aligns perfectly, however bullets do not. Is there a simple and easy way to do so with CSS?

Code:

<ul style="text-align: right">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

Even if I put the rules for LI elements directly to be aligned to the rigth, it does not work.

EDIT I have attached an image showing what I want to achieve: On the right is what I want. On the left is what I have

like image 286
lukas.pukenis Avatar asked May 03 '12 12:05

lukas.pukenis


People also ask

How do you right-align a list in CSS?

To make a right-aligned version of the list, only three changes need to occur. First, set the "UL" "text-align" to "right". Second, change the left "background-position" from "0" to "100%" - which makes the image align up with the right edge. And finally change "padding-left" to "padding-right".

How do you align bullet points in CSS?

You need to bring the bullet points inside the content flow by using list-style-position:inside; , and then center align the text.


2 Answers

If you need to align the bullets with the text you can use the list-style-position attribute, as follow:

.theList
{
    text-align: right;
    list-style-position: inside;
}​
like image 178
Adriano Repetti Avatar answered Sep 18 '22 13:09

Adriano Repetti


Use direction:

direction: rtl;

It is generally used for right to left languages.

edit:

Float each to the right and clear both.

float: right;
clear: both;
like image 27
Madara's Ghost Avatar answered Sep 20 '22 13:09

Madara's Ghost