CSS Live Demo: text-align Click the demo button below!
selector {
    text-align: left | right | start | end | center | justify
}
/* Keyword values */
text-align: left;
text-align: right;
text-align: start;
text-align: end;
text-align: center;
text-align: justify;

/* Global values */
text-align: inherit;
text-align: initial;
text-align: revert;
text-align: revert-layer;
text-align: unset;
text-align: justify Note: This issue is especially pronounced in English text, where uneven word spacing can create distracting visual gaps.
<style>
    p {
        background-color: yellowgreen;
        text-align: justify;
    }
</style>
<p>text-align: justfiy;</p>
Rendered Output In other words, if a line of text does not naturally fill the line box (such as the last line of a paragraph), it remains aligned to the start edge rather than being stretched.
<style>
    span {
        text-align: center;
    }
</style>
<span>text-align: center;</span>
Rendered Output Applying text-align: center to the <span> element:
<style>
    span {
        text-align: center;
        background-color: yellowgreen;
    }
</style>
<span>text-align: center;</span>
Rendered Output Applying text-align: center with a background color:
<div class="container">
    <img class="image" src="image-source.jpg" alt="Image">
</div>
.container {
    background-color: orange;
    text-align: center; /* Aligns inline-level descendants (text, images, etc.)                
                           within the horizontal space of the container */
}
.image {
    width: 200px;
    vertical-align: top;
}
Rendered Output
<style>
[type="text"] {
    padding: 0.5em;
    outline: none;
    border: none;
    border-bottom: 2px solid;
    text-align: center;
    transition: all 0.3s; /* Centers the input text and placeholder */
    width: 300px;
}
[type="text"]:focus {
    border-color: #006466;
    background-color: rgba(0, 116, 117, .1);
}
[type="text"]::placeholder {
    transition: opacity 0.3s;
}
[type="text"]:focus::placeholder {
    opacity: 0;
}
</style>
<input type="text" placeholder="Type here...">
Rendered Output