In typography, an indentation is the introduction of one or more blank characters in front of a line. It is usually used in texts that are aligned to the left. This example we will see how to create a first line indent with CSS. In the case of first line indentation, blank characters are only introduced in the first line of a paragraph.
An example of a first line indentation would be the following:
In a place in La Mancha, the name of which I do not want to remember, not long ago there lived one of those gentlemen with a lance in a shipyard, an old buckler, a skinny nag and a racing greyhound. A pot of something more beef than mutton, salpicón most nights, duels and losses on Saturdays, lentils on Fridays, some extra palomino on Sundays, consumed three parts of his property.
If we want to use the first line indentation on our web page we can do it using style sheets CSS. Specifically we need to handle one of the properties that manipulate text in CSS which is the
text-indent
.
This property establishes a separation between the border and the beginning of the first sentence of a paragraph. The value that we can give to the property can be an absolute or percentage value. So its syntax is the following:
text-indent : [ <length-percentage> ] && hanging? && each-line?
This way our code CSS would look like this:
p.firstline {
text-indent: 40px;
}
We must see that we are applying the property to a paragraph that is represented by an element
p
, but when it applies the class «firstline». That is, it will work when we include a paragraph within our page HTML, whose value for the attribute class is «primeralinea».
The paragraph would be as follows:
<p class="primeralinea">In a place in La Mancha, whose name I do not want to remember, not long ago there lived one of those gentlemen with a lance in a shipyard, an old buckler, a skinny nag, and a greyhound for racing. A pot of something more beef than mutton, salpicón most nights, duels and losses on Saturdays, lentils on Fridays, some extra palomino on Sundays, consumed three parts of his property.</p>
This way we will have configured our first line indentation with CSS. Do you use this type of indentation in your web text designs? Share it in the comments so that we can all be enriched by the experiences.
