Forum How do I...?

Indent paragraphs after the first

jean
I want the first paragraph to start flush left, and subsequent ones to be indented. The first rule takes care of that. Unfortunately the DocBook stylesheets use a '<p class="title">' for the title of an abstract. The second rule is supposed to cure that, but it doesn't. The first rule's indent governs. Any way to fix?

/* Indent paragraphs after the first */
p + p::first-letter {
    padding-left: 0.5em;
}
/* But don't indent paragraphs after a "title" paragraph */
p[class="title"] + p::first-letter {
    padding-left: 0em;
    background: red; /* for debugging */
}
mikeday
Some suggestions:

- the text-indent property applied to the paragraphs may be easier than using padding on ::first-letter. (The hanging keyword allows you to create hanging indents).

- p[class="title"] may be replaced with p.title

If you change the rules to use ~ and not +, then they will apply to all following paragraphs, not just the first.

However, I'm not sure why you're second rule isn't applying properly to at least the first paragraph following the title. The red seems to show up, but it's not cancelling out the padding. Perhaps a bug in Prince.
jean
mikeday wrote:
- the text-indent property applied to the paragraphs may be easier


Ah, that looks like the proper way. I started out looking for the :first-line
selector, but doesn't look like prince has that.

mikeday wrote:
- p[class="title"] may be replaced with p.title


Duh, of course :-] I was looking to create *one* rule with p[class!="title"] (all paragraphs that don't have class="title"), but that doesn't exist. Ended up with this construct without simplifying all the way.

mikeday wrote:
If you change the rules to use ~ and not +, then they will apply to all following paragraphs, not just the first.


Hmm? They already apply to all following paragraphs, AFAICS. And If I have say <p>...</p><div>...</div><p>...</p><p>...</p> then I want the first two p's flush left, and only the third with first line indented.

mikeday wrote:
However, I'm not sure why you're second rule isn't applying properly


Yes, that was my main issue as well.
jean
mikeday wrote:
- the text-indent property applied to the paragraphs may be easier


Works great :-)

Stupidly opaque property name though (blame it on the spec).

It looks like prince's 'hanging' keyword (which is not in the spec) overlaps with a negative text-indent (which is not in prince, at least not in the docs)?
mikeday
Well, text-indent does indent text, so it does what it says on the box. :)

A negative text indent would drag the first line to the left, into the margin, whereas a positive hanging indent would push all subsequent lines to the right, so they have a different effect. Hanging indents come from CSS 3.
jean
mikeday wrote:
Well, text-indent does indent text, so it does what it says on the box. :)


Yes, but it doesn't say which text. The only reasonable interpretation is that it's the paragraph's text. The fact that it's actually the paragraph's first line is just as arbitrary as if it was every second line on alternate sundays. But I'm just bitching :P

mikeday wrote:
so they have a different effect.


Yeah, but overlapping, as you could accomplish the same thing with both, used in combination with paragraph margin rules.
mikeday
It seems that there was a bug in Prince concerning the selector specificity, which is why the second rule was not correctly applying in all cases. We have fixed the bug for the next maintenance release. Thanks for reporting the issue. :)
jean
Yay :D
mikeday
The Prince 6.0 rev 6 maintenance release is now out, and includes a fix for the sibling selector bug. Thanks again for reporting the issue! :)
jean
mikeday wrote:
The Prince 6.0 rev 6 maintenance release is now out


Cool, downloading :)