Thread: CSS Question
View Single Post
Old 11-09-2020, 12:51 PM   #5
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,220
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by DNSB View Post
One problem with using that solution is that it does not seem to allow using <p class="noindent"> to not indent a single paragraph. I've attached a sample image from calibre's ebook-viewer where the last two paragraphs should not have an indent.
That was just an example for the specific code shared by the OP. But to address your case either, you can just ADD my suggestion to the original CSS:

Code:
p {
  text-indent: 2em;
}
.noindent {
  text-indent: 0em;
}
.noindent p {
  text-indent: 0em
}
See that a more specific rule takes precedence over the general one.

In other cases, you might need to apply it to everything but a specific class (let's call it 'special'); then you could declare it like this:

Code:
.noindent p:not(.special) {
  text-indent: 0em
}
If you want just the first instance of <p> to have that style, then use the '+' sign. This is good for styling first paragraphs without using classes, or for a drop cap (alongside with pseudo-selector 'first-letter'):

Code:
h1 + p {
  text-indent: 0em
}

Last edited by thiago.eec; 11-09-2020 at 01:43 PM. Reason: typo
thiago.eec is offline   Reply With Quote