Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

indent body text but not blockquotes and images

indent body text but not blockquotes and images

Problem

I want to indent all text in the Body of a document without indenting blockquotes or images. In the style.css if I add:

body {
    text-indent: 2em;
}

The text is indented but so are the blockquotes and images.

Problem courtesy of: Tyler Rinker

Solution

The text-indent property applies to block containers only, so it does not affect images. But a block containing an image is affected and this may affect the position of an image.

You should set text-indent only on those blocks that you would like to have their first lines indented. Normally this means something like p { text-indent: 1em; }. If you want blocks other than p elements to be affected, too, write suitable selector list instead of the simple p.

Solution courtesy of: Jukka K. Korpela

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

indent body text but not blockquotes and images

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×