CSS Text Alignment
The text-align property controls how inline content such as text is positioned horizontally within its container.
The <text-align> property sets the horizontal alignment of inline content inside a block-level element. It affects the text, not the block itself, so it decides where the words sit within the available width.
The main values
Centering a heading
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
}
</style>
</head>
<body>
<h1>About Us</h1>
</body>
</html>Justified paragraph text
<!DOCTYPE html>
<html>
<head>
<style>
.article p {
text-align: justify;
}
</style>
</head>
<body>
<div class="article">
<p>This paragraph stretches so both edges line up evenly along the sides.</p>
</div>
</body>
</html>Note: text-align only moves inline content. To center a block element itself, use margin: 0 auto with a set width instead.