Home > Enterprise >  How can I center subtitle text in quarto?
How can I center subtitle text in quarto?

Time:07-13

I would like to center one of my sub-headers not the text below it. I tried the code below and it centers the subheading and also the text in the subsection.

---
title: "how do I center only a title"
format: html
---
### Something

something not centered

### A Centered Subheading {style="text-align: center;"}

Blah blah

- Blah
- More blah
- still more blah

### Somethingelse

not centered

What is the proper way to center just the subtitle?

CodePudding user response:

You can center a specific header using css. Simply define a class name for that header like here I have used .test as a class applied to that header. And then in a separate css file styles.css, we need to write the style rules.

---
title: "how do I center only a title"
format: html
css: styles.css
---

### Something

something not centered


### A Centered Subheading {.test}


Blah blah

- Blah
- More blah
- still more blah

### Somethingelse

not centered

And In the styles.css file

.test h3 {
  text-align: center;
}

Output

quarto_doc_with_a_header_centered

  • Related