Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Quarto, how do I write inline CSS?

Tags:

css

quarto

I would like to color a word in a sentence that is being rendered in quarto to HTML. In R Markdown I would just add a css tag but I don't see how to do that in quarto. The quarto documentation says that it is possible to write inline css but there is no example. There is a hyperlink that shows a R Markdown example:

```{css, echo=FALSE}
body {
  color: red;
}
```

When I do that, quarto displays the code as a code block and does not use the CSS.

How do I add a CSS code block to a quarto document?

like image 247
itsMeInMiami Avatar asked Mar 23 '26 04:03

itsMeInMiami


1 Answers

Just surround the word you want to style by [] and write the styles in {}, like this

the color is [red]{style="color: red;"}

so the word red will be in the color red.

To add more details,

---
title: "inline style"
format: html
---

## inline style in Quarto

We can apply styles to a sentence or a word 
by creating spans using `[]` to surround the
sentence or word that we want to style and 
use `{}` to define the style that we want to 
apply. For example,

The color of this word is [red]{style="color: red;"}. 
And [this line has a yellow background]{style="background-color: yellow"}.

After rendering, we get this,

quarto-doc-with-inline-css

like image 83
Shafee Avatar answered Mar 26 '26 13:03

Shafee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!