CSS Left Alignment

CSS Left Alignment

In web design, alignment is a very important concept. Left alignment refers to aligning elements or text along the left edge of a page. In CSS, we can use different properties and values ​​to achieve left alignment. This article will explain how to achieve left alignment using CSS in detail and provide several code examples to help readers better understand.

1. Left Aligning Text

In CSS, we can use the text-align property to control the alignment of text. To align the text to the left, set the value of the text-align property to left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.left-align { 
text-align: left; } 
</style> 
</head> 
<body> 
<p class="left-align">This is a left-aligned text, geek-docs.com</p> 
</body> 
</html> 

Output:

CSS Left Align

Run the above code and you’ll see the text is left-aligned.

2. Left-Aligning Elements

In addition to text, we can also achieve left-aligned elements by setting the float property. Setting the float property to left causes the element to float to the left, achieving a left-aligned effect.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.left-align { 
float: left; 
width: 50%; 
background-color: lightblue; 
} 
</style> 
</head> 
<body> 
<div class="left-align">This is a left-aligned element, geek-docs.com</div> 
<div>This is another element</div> 
</body> 
</html> 

Output:

CSS Left Align

In the above code, the first div element is set to float left, achieving the left alignment effect.

3. Left-aligned list

In CSS, we can use the list-style-position property to control the position of list item markers. To left-align list items, set the value of the list-style-position property to inside.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
ul { 
list-style-position: inside; 
} 
</style> 
</head> 
<body> 
<ul> 
<li>List Item 1 - geek-docs.com</li> 
<li>List Item 2</li> 
<li>List Item 3</li> 
</ul> 
</body> 
</html> 

Output:

CSS Left Align

In the above code, the unordered list tag is placed inside the list item, achieving left alignment.

4. Left-aligning a table

In CSS, we can use the text-align property to control the alignment of table content. Setting the text-align property to left will left-align the table content.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
table { 
width: 100%; 
} 
th, td { 
border: 1px solid black; 
padding: 5px; 
text-align: left; 
} 
</style> 
</head> 
<body> 
<table> 
<tr> 
<th>Header 1</th> 
<th>Header 2</th> 
</tr> 
<tr> 
<td>Data 1 - geek-docs.com</td> 
<td>Data 2</td> 
</tr> 
</table> 
</body> 
</html> 

Output:

CSS left aligned

The table content in the above code is displayed left-aligned.

5. Left-Aligning Images

In CSS, we can use the float property to control the alignment of https://coder-cafe.com/wp-content/uploads/2025/09/images. Setting the float property’s value to left causes the image to float to the left, achieving a left-aligned effect.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
img { 
float: left; 
margin-right: 10px; 
} 
</style> 
</head> 
<body> 
<img src="https://coder-cafe.com/wp-content/uploads/2025/09/image.jpg" alt="Image Aligned Left"> 
<p>This is a left-aligned image, geek-docs.com</p> 
</body> 
</html> 

Output:

CSS Left Align

The image in the above code is set to float left, achieving a left-aligned effect.

6. Left-Aligning a Text Box

In CSS, we can use the text-align property to control the alignment of text within a text box. Setting the text-align property to left will left-align the text within the text box.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
input[type="text"] { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<input type="text" value="Text box left aligned - geek-docs.com"> 
</body> 
</html> 

Output:

CSS Left Align

The text in the text box in the above code is displayed with left alignment.

7. Left-Align Paragraphs

In CSS, we can use the text-align property to control the alignment of text within a paragraph. Setting the text-align property to left will align the text within a paragraph to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
p { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<p>This is a left-aligned paragraph. geek-docs.com</p> 
</body> 
</html> 

Output:

CSS Left Align

The text in the paragraph in the above code is displayed left-aligned.

8. Block-Align Text Left

In CSS, we can use the display property to control the display of an element. Setting the display property to block displays the element as a block-level element, achieving left alignment.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.left-align { 
display: block; 
width: 50%; 
background-color: lightblue; 
} 
</style> 
</head> 
<body> 
<div class="left-align">This is a left-aligned text block, geek-docs.com</div> 
</body> 
</html> 

Output:

CSS Left Align

The text block in the above code is set as a block-level element, achieving left-alignment.

9. Link Left-Alignment

In CSS, we can use the text-align property to control the alignment of text within a link. Setting the text-align property to left will left-align the text within the link.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
a { 
text-align: left; 
} 
</style> 
</head> 
<body> 
This is a left-aligned link 
</body> 
</html> 

Output:

CSS Left Align

The text in the link in the above code is displayed left-aligned.

10. Left-Align Buttons

In CSS, we can use the text-align property to control the alignment of text within a button. Setting the text-align property to left will align the text within the button to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
button { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<button>Button Left Align - geek-docs.com</button> 
</body> 
</html> 

Output:

CSS Left Align

The text in the button in the above code is displayed left-aligned.

11. Left-align text links

In CSS, we can use the text-align property to control the alignment of text within a text link. Setting the text-align property to left will align the text within the text link to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.link { 
text-align: left; 
} 
</style> 
</head> 
<body> 
This is a left-aligned text link 
</body> 
</html> 

Output:

CSS Left Align

The text in the text link in the above code is displayed with the text aligned to the left.

12. Left-Align Text Lists

In CSS, we can use the text-align property to control the alignment of text within a text list. Setting the text-align property to left will left-align the text within a text list.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.list { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<ul class="list"> 
<li>List item 1 - geek-docs.com</li> 
<li>List item 2</li> 
<li>List item 3</li> 
</ul> 
</body> 
</html> 

Output:

CSS Left Align

The text in the text list in the above code is left-aligned.

13. Left-aligned Text Block List

In CSS, we can use the display property to control the display of an element. Setting the display property to block displays the element as a block-level element, thus achieving the left-aligned effect of a text block list.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.block-list { 
display: block; 
width: 50%; 
background-color: lightblue; 
} 
</style> 
</head> 
<body> 
<div class="block-list"> 
<p>List Item 1 - geek-docs.com</p> 
<p>List Item 2</p> 
<p>List Item 3</p> 
</div> 
</body> 
</html> 

Output:

CSS left-aligned

The text block list in the above code is set as a block-level element, achieving left alignment.

14. Left-Aligning Text Tables

In CSS, we can use the text-align property to control the alignment of table content. Setting the text-align property to left will align the table content to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
table { 
width: 100%; 
} 
th, td { 
border: 1px solid black; 
padding: 5px; 
text-align: left; 
} 
</style> 
</head> 
<body> 
<table> 
<tr> 
<th>Header 1</th> 
<th>Header 2</th> 
</tr> 
<tr> 
<td>Data 1 - geek-docs.com</td> 
<td>Data 2</td> 
</tr> </table> 
</body> 
</html> 

Output:

CSS Left Align

The table contents in the above code are displayed left-aligned.

15. Left-Aligning a Text Box

In CSS, we can use the text-align property to control the alignment of text within a text box. Setting the text-align property to left will left-align the text within the text box.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
input[type="text"] { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<input type="text" value="Text box left aligned - geek-docs.com"> 
</body> 
</html> 

Output:

CSS Left Align

The text in the text box in the above code is displayed with the text aligned to the left.

16. Left-Align Paragraph Text

In CSS, we can use the text-align property to control the alignment of text within a paragraph. Setting the text-align property to left will left-align the text within a paragraph.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
p { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<p>This is a left-aligned paragraph. geek-docs.com</p> 
</body> 
</html> 

Output:

CSS Left Align

The text in the paragraph in the above code is displayed left-aligned.

17. Left-Align Text Links

In CSS, we can use the text-align property to control the alignment of text within a text link. Setting the text-align property to left will align the text within the text link to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.link { 
text-align: left; 
} 
</style> 
</head> 
<body> 
This is a left-aligned text link 
</body> 
</html> 

Output:

CSS Left Align

The text in the text link in the above code is displayed with the text aligned to the left.

18. Left-Align Text Buttons

In CSS, we can use the text-align property to control the alignment of text within a button. Setting the text-align property to left will align the text within the button to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
button { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<button>Button Left Align - geek-docs.com</button> 
</body> 
</html> 

Output:

CSS Left Align

The text in the button in the above code is displayed left-aligned.

19. Left-Align Text Lists

In CSS, we can use the text-align property to control the alignment of text within a text list. Setting the text-align property to left will left-align the text within a text list.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.list { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<ul class="list"> 
<li>List item 1 - geek-docs.com</li> 
<li>List item 2</li> 
<li>List item 3</li> 
</ul> 
</body> 
</html> 

Output:

CSS Left Align

The text in the text list in the above code is left-aligned.

20. Left-aligned Text Block List

In CSS, we can use the display property to control the display of an element. Setting the display property to block displays the element as a block-level element, thus achieving the left-aligned effect of a text block list.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.block-list { 
display: block; 
width: 50%; 
background-color: lightblue; 
} 
</style> 
</head> 
<body> 
<div class="block-list"> 
<p>List Item 1 - geek-docs.com</p> 
<p>List Item 2</p> 
<p>List Item 3</p> 
</div> 
</body> 
</html> 

Output:

CSS left-aligned

The text block list in the above code is set as a block-level element, achieving left alignment.

21. Left-Aligning Text Tables

In CSS, we can use the text-align property to control the alignment of table content. Setting the text-align property to left will align the table content to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
table { 
width: 100%; 
} 
th, td { 
border: 1px solid black; 
padding: 5px; 
text-align: left; 
} 
</style> 
</head> 
<body> 
<table> 
<tr> 
<th>Header 1</th> 
<th>Header 2</th> 
</tr> 
<tr> 
<td>Data 1 - geek-docs.com</td> 
<td>Data 2</td> 
</tr> </table> 
</body> 
</html> 

Output:

CSS Left Align

The table contents in the above code are displayed left-aligned.

22. Left-Aligning Text Boxes

In CSS, we can use the text-align property to control the alignment of text within a text box. Setting the text-align property to left will left-align the text within the text box.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
input[type="text"] { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<input type="text" value="Text box left aligned - geek-docs.com"> 
</body> 
</html> 

Output:

CSS Left Align

The text in the text box in the above code is displayed with left alignment.

23. Left-Align Paragraph Text

In CSS, we can use the text-align property to control the alignment of text within a paragraph. Setting the text-align property to left will left-align the text within a paragraph.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
p { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<p>This is a left-aligned paragraph. geek-docs.com</p> 
</body> 
</html> 

Output:

CSS Left Align

The text in the paragraph in the above code is displayed left-aligned.

24. Left-Align Text Links

In CSS, we can use the text-align property to control the alignment of text within a text link. Setting the text-align property to left will align the text within the text link to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
.link { 
text-align: left; 
} 
</style> 
</head> 
<body> 
This is a left-aligned text link 
</body> 
</html> 

Output:

CSS Left Align

The text in the text link in the above code is displayed with the text aligned to the left.

25. Left-Align Text Buttons

In CSS, we can use the text-align property to control the alignment of text within a button. Setting the text-align property to left will align the text within the button to the left.

<!DOCTYPE html> 
<html> 
<head> 
<style> 
button { 
text-align: left; 
} 
</style> 
</head> 
<body> 
<button>Button Left Align - geek-docs.com</button> 
</body> 
</html> 

Output:

CSS Left Align

The text in the button in the above code is displayed left-aligned.

Leave a Reply

Your email address will not be published. Required fields are marked *