View Single Post
Old 06-17-2016, 03:32 AM   #2
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by AlexBell View Post
I often set the first paragraph of a blockquote to the left - (text-indent: 0)

Is the CSS which I can apply to the blockquote so that the first paragraph in it is not indented?

It's easy to ensure that the first paragraph after a blockquote is not indented, but I'm talking about the first paragraph within the blockquote.

You mean like this?

Code:
// Make first paragraph directly enclosed by blockquote be flush left.
blockquote > p {
    text-indent: 0;
}

// Make subsequent paragraphs directly enclosed by blockquote be
// indented as usual.
blockquote > p + p {
    text-indent: 2em; // or whatever
}
The > selector is the child selector, matching the p tag when it is immediately inside the blockquote tag. Or if you remove that selector and replace it with just whitespace, the rule applies to any p tag that's a descendant of the blockquote tag.

The + selector is the next sibling selector, matching the p tag when it is immediately after another p tag. Or use the ~ selector if your reading system supports it, but that isn't guaranteed in EPUB-2-based readers.

If you know that the paragraph tag will be the first child of its parent, you could also do:

Code:
// Make most paragraphs directly enclosed by blockquote be
// indented as usual.
blockquote > p {
    text-indent: 2em; // or whatever
}

// Make first paragraph directly enclosed by blockquote be flush left.
blockquote > p:first-child {
    text-indent: 0;
}
That approach has the approach of working correctly without the need to add more rules if you have non-p tags inside the blockquote tag, but the disadvantage of not modifying the p tag if there are other tags before it. Then again, if there are other tags before it, you could probably just use those with the + selector instead, so....

Last edited by dgatwood; 06-17-2016 at 03:46 AM.
dgatwood is offline   Reply With Quote