Skip to content


How to justify text in WordPress

I’ve always had a thing for justified text, but never went through the (really small!) trouble of fixing the ugly text alignment in WordPress. Justifying your posts, though, is quite trivial. I’ll focus here on how it’s done on the Carrington theme because that’s what I use, but the general principle is:

1) Post contents are contained within a div with classes entry-content and full-content. I suspect that the first is always used, while the latter is only used when the post is displayed in full.
2) Find your theme’s CSS files, and somewhere add code to justify the text (text-align:justify) in the entry-content class

So, to apply this to Carrington:

1) In your admin panel, go to Appearance → Editor
2) Open up css.php (its full name is css/css.php, but for some reason the folder doesn’t appear in the list)
3) Just before ?>, add echo ".entry-content{text-align:justify}\n\n";
4) Click “Update file” to save it
5) Go back to your blog’s homepage and refresh (maybe CTRL+F5 to flush the CSS in cache)

For those curious and not knowing much about PHP, css.php merges several CSS files into a single one. The line we added in it simply adds CSS .entry-content{text-align:justify} at the end of the merger. That’s not very clean, but it’s good enough considering that Carrington is barely updated nowadays (if css.php gets overwritten by an update, you’ll need to reapply this modification).

Posted in WordPress.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA