There are various different methods available in CSS that can be used to align a link to the right side. However, the most easiest and commonly used method is to use the text-align property on the parent element.
In this method, all you need to do is put the link i.e. <a> tag inside a div element, and then simply apply text-align: right;
on this parent div element.
This will automatically align the link to the right side of the parent container.
See the following example:
Example:
div{ text-align: right; }
Align Link to the Right Side using CSS Float
The above method is only valid if you want to align all the links to the right side of their parent container. But, if you want only a few links align to the right then the above method will not work.
In that case CSS float
property would be the best choice. The float property allows you to float the elements to the left or right side based on the available space.
So, if you want to align a link to the right side, you have to simply use float: right;
.
See the following example:
Example:
a.right{ float: right; }