EN
CSS - text align left
0 points
In this article, we would like to show you how to align text to the left using CSS.
Quick solution:
xxxxxxxxxx
1
.element {
2
text-align: left;
3
}
In this example, we create a style for .element
class that uses text-align
property to align text inside div
element to the left side.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
.element {
7
text-align: left; /* <---------- required */
8
border: 1px solid lightgray;
9
}
10
11
</style>
12
</head>
13
<body>
14
<div class="element">Some text here...</div>
15
<br />
16
<div class="element">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
17
</body>
18
</html>
Note:
You can also use
text-align: start
which is a new standard solution, however it is supported by all major browsers since 2020. For legacy purposes, we usetext-align: left
in the example.