Quote:
Originally Posted by AlexBell
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....