CSS: Indenting text

TypeTip series:
In this small series I take a look at some useful yet less unknown typography specific CSS properties.

A lot of developers tend to do the bare minimum when it comes to implementing proper website typography. This isn’t an insult – I’…


This content originally appeared on Ugly Duck and was authored by Bradley Taunt

TypeTip series:
In this small series I take a look at some useful yet less unknown typography specific CSS properties.

A lot of developers tend to do the bare minimum when it comes to implementing proper website typography. This isn’t an insult - I’m happy that typography is given any thought at all during development, I just believe more can always be done to improve upon it.

In today’s TypeTip we’re going to play around with the text-indent property, look into when it’s best to use it and how to implement it properly.

The property and browser support

Browser support is actually pretty great for such a regularly over-looked CSS property. All major desktop and mobile browsers support it:

Text indent browser compatibility Full support across all browsers.

Now that doesn’t mean you should just slap this property on all your type elements and call it a day - there are specific use cases for text-indent and some basic rules to follow:

Use Cases

  1. Increasing readability of large text blocks that would otherwise overwhelm the reader
  2. Replicating book or report typography layouts

Basic Rules

  1. Best to set this property on inner type children only - meaning items like p or blockquotes instead of main headings
  2. When used on paragraph tags it’s best to target only p elements that directly follow a sibling tag (see “The CSS” below)

The CSS

Adding the property is extremely trivial, all you need is the following:

/* Best practice for paragraphs */
p + p {
    text-indent: 1rem; /* whatever you want */
}

Let’s see it in action

See the Pen Simple text-indent by Bradley Taunt (@bradleytaunt) on CodePen.


This content originally appeared on Ugly Duck and was authored by Bradley Taunt


Print Share Comment Cite Upload Translate Updates
APA

Bradley Taunt | Sciencx (2019-04-05T00:00:00+00:00) CSS: Indenting text. Retrieved from https://www.scien.cx/2019/04/05/css-indenting-text/

MLA
" » CSS: Indenting text." Bradley Taunt | Sciencx - Friday April 5, 2019, https://www.scien.cx/2019/04/05/css-indenting-text/
HARVARD
Bradley Taunt | Sciencx Friday April 5, 2019 » CSS: Indenting text., viewed ,<https://www.scien.cx/2019/04/05/css-indenting-text/>
VANCOUVER
Bradley Taunt | Sciencx - » CSS: Indenting text. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2019/04/05/css-indenting-text/
CHICAGO
" » CSS: Indenting text." Bradley Taunt | Sciencx - Accessed . https://www.scien.cx/2019/04/05/css-indenting-text/
IEEE
" » CSS: Indenting text." Bradley Taunt | Sciencx [Online]. Available: https://www.scien.cx/2019/04/05/css-indenting-text/. [Accessed: ]
rf:citation
» CSS: Indenting text | Bradley Taunt | Sciencx | https://www.scien.cx/2019/04/05/css-indenting-text/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.