Prose
The prose component provides proper styling for rendered Markdown.
Classes
Section titled Classes| Class | Output |
|---|---|
.s-prose |
Adds proper styling for rendered Markdown. |
.s-prose__sm |
Decreases the base font size and line height. |
Examples
Section titled ExamplesMinimal
Section titled MinimalWe modified this test document from the folks at Tailwind to demonstrate and explain our design choices.
<div class="s-prose">
…
</div>
Stacks adds a new s-prose class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
<article class="s-prose">
<h1>Garlic bread with cheese: What the science tells us</h1>
<p>
For years parents have espoused the health benefits of eating garlic bread with cheese to their
children, with the food earning such an iconic status in our culture that kids will often dress
up as warm, cheesy loaf for Halloween.
</p>
<p>
But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
springing up around the country.
</p>
<!-- ... -->
</article>
What to expect from here on out
What follows from here is just a bunch of absolute nonsense we’ve written to dogfood the component itself. It includes every sensible typographic element we could think of, like bold text, unordered lists, ordered lists, code blocks, block quotes, and even italics.
It’s important to cover all of these use cases for a few reasons:
- We want everything to look good out of the box.
- Really just the first reason, that’s the whole point of the plugin.
- Here’s a third pretend reason though a list with three items looks more realistic than a list with two items.
Now we’re going to try out another header style.
Typography should be easy
So that’s a header for you—with any luck if we’ve done our job correctly that will look pretty reasonable.
Something a wise person once told me about typography is:
Typography is pretty important if you don’t want your stuff to look like trash. Make it good then it won’t be bad.
It’s probably important that images look okay here by default as well:
Now I’m going to show you an example of an unordered list to make sure that looks good, too:
- So here is the first item in this list.
- In this example we’re keeping the items short.
- Later, we’ll use longer, more complex list items.
And that’s the end of this section.
What if we stack headings?
We should make sure that looks good, too.
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
When a heading comes after a paragraph …
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let’s see what a more complex list would look like.
-
I often do this thing where list items have headings.
For some reason I think this looks cool which is unfortunate because it’s pretty annoying to get the styles right.
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn’t write this way.
-
Since this is a list, I need at least two items.
I explained what I’m doing already in the previous list item, but a list wouldn’t be a list if it only had one item, and we really want this to look realistic. That’s why I’ve added this second list item so I actually have something to look at when writing the styles.
-
It’s not a bad idea to add a third item either.
I think it probably would’ve been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
Code should look okay by default.
Here’s what a default tailwind.config.js file looks like at the time of writing:
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
}
Hopefully that looks good enough to you.
What about nested lists?
Nested lists basically always look bad which is why editors like Medium don’t even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
- Nested lists are rarely a good idea.
- You might feel like you are being really “organized” or something but you are just creating a gross shape on the screen that is hard to read.
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
- Nesting tons of folders in your source code is also not helpful.
- Since we need to have more items, here’s another one.
- I’m not sure if we’ll bother styling more than two levels deep.
- Two is already too much, three is guaranteed to be a bad idea.
- If you nest four levels deep you belong in prison.
- Two items isn’t really a list, three is good though.
- Again please don’t nest lists if you want people to actually read your content.
- Nobody wants to look at this.
- I’m upset that we even have to bother styling this.
The most annoying thing about lists in Markdown is that <li> elements aren’t given a child <p> tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
-
For example, here’s another nested list.
But this time with a second paragraph.
- These list items won’t have
<p>tags - Because they are only one line each
- These list items won’t have
-
But in this second top-level list item, they will.
This is especially annoying because of the spacing on this paragraph.
-
As you can see here, because I’ve added a second line, this list item now has a
<p>tag.This is the second line I’m talking about by the way.
-
Finally here’s another list item so it’s more like a list.
-
-
A closing list item, but with no nested list, because why not?
And finally a sentence to close off this section.
There are other elements we need to style
I almost forgot to mention links, like Stack Overflow.
We even included table styles, check it out:
| Wrestler | Origin | Finisher |
|---|---|---|
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor’s Edge |
We also need to make sure inline code looks good, like if I wanted to talk about <span> elements.
Sometimes I even use code in headings
Another thing I’ve done in the past is put a code tag inside of a link, like if I wanted to tell you about the stackexchange/stacks repository.
We still need to think about stacked headings though.
Let’s make sure we don’t screw that up with h4 elements, either.
Phew, with any luck we have styled the headings above this text and they look pretty good.
We should also make sure we're styling h5 elements as well.
Let’s add a closing paragraph here so things end with a decently sized block of text. I can’t explain why I want things to end that way but I have to assume it’s because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
And, finally, an h6.
Ultimately, though, we also want to support the h6 headers.
What I’ve written here is probably long enough, but adding this final sentence can’t hurt.
Full Markdown spec
Section titled Full Markdown specThis example includes the full kitchen-sink collection of everything the Markdown spec includes.
The Comprehensive Formatting Test
Code Formatting
- Inline code formatting or code spans
- Normal backticks
System.out.println("Hello World!");. - Escaped backticks:
for line in `someCommand` - A single backtick character in a line won't form a code block '`'.
- There are two backtick characters ('`') in this line ('`').
- Normal backticks
- Block code formatting
System.out.println("Hello World!");
System.out.println("Code Block!");
<div class="s-progress s-progress__stepped">
<div class="s-progress--step is-complete">
<a href="…" class="s-progress--stop">
@Svg.CheckmarkSm
</a>
<div class="s-progress--bar s-progress--bar__right"></div>
<a class="s-progress--label">…</a>
</div>
<div class="s-progress--step is-complete">
<a href="…" class="s-progress--stop">
@Svg.CheckmarkSm
</a>
<div class="s-progress--bar s-progress--bar__left"></div>
<div class="s-progress--bar s-progress--bar__right"></div>
<a class="s-progress--label">…</a>
</div>
<div class="s-progress--step is-active">
<div class="s-progress--stop"></div>
<div class="s-progress--bar s-progress--bar__left"></div>
<div class="s-progress--bar s-progress--bar__right"></div>
<div class="s-progress--label">…</div>
</div>
<div class="s-progress--step">
<div class="s-progress--stop"></div>
<div class="s-progress--bar s-progress--bar__left"></div>
<div class="s-progress--label">…</div>
</div>
</div>
-
HTML and other markdown are not supported within code spans or code blocks.
``` </code> *Not in code!* <code> ```</code> *Not in code!* <code>
Line Breaks
-
This is one line. This was intended to be on the next line, but it appears on the same line.
-
This is one paragraph. It has some sentences.
This is intended to be a second paragraph.
-
This is one line.
This is intended to be on the next line.
Italics and Bold
-
This is italic text. This is italic too.
-
This is bold text. This is bold too.
-
underscores only and asterisks only and underscore and asterisk and asterisk and underscore.
-
Four!
-
Five!
-
Two and Two!
-
One and One!
Links
-
Inline links:
- Meta Stack Exchange
- Meta Stack Exchange with tooltip
- Meta Stack Exchange with tooltip
- Meta Stack Exchange with tooltip
- [Escaped link to Meta Stack Exchange](https://meta.stackexchange.com)
- No protocol link to Meta Stack Exchange
-
Reference links:
-
Bare URLs
- Bare URLs get turned into links. http://example.com
- Angle brackets force links. https://www.google.com
Images
- Inline images, similar to links but with leading
!:- A normal image

- An image with a tooltip

- Escaped image so as to not render the actual image
)
- A normal image
- Reference images:
- Image links - surround an image with a link.

- A bunch of images in a row



Headers
-
Heading 1
-
Heading 2
-
Heading 3
-
Heading 4
-
Heading 5
-
Heading 6
- Escaped
## Not a heading -
Italic Header
Horizontal Rules
Blockquotes
A general quote With multiple lines
First level!
Second level!
Third level!
Need blank line and one less Spanning a blank line
-
A quote within a list item
-
One can nest blockquotes with multiple
>characters.First level!
Second level!
Third level!
Need blank line and one less < to go back to second.
Same idea for back to first.
-
Escape a
>character with a backslash.> I want a
>! -
Markdown within a blockquote
Enjoy this
unicorn!
-
Code formatting works within a blockquote. Indenting requires 5 spaces: 1 for the blockquote, and 4 for the code indention.
System.out.println("Hello World!");Inline:
System.out.println("Hello World!");Code fence:
System.out.println("Hello World!");
Lists
- Unordered Lists
- One
- Two
- Three
- Ordered Lists
- One
- Two
- Three
- Multiple lines within list items: indent 4 spaces, or do we need to?
- Same line Continuation of the same line
- Next line Not indented
- Next line Continuation of the same line
- Nested lists: indent 4 spaces.
- Top level
- Mid level
- Bottom level
- Mid level
- Bottom level
- Mid level
- Top level
- Mid level
- Bottom level
- Mid level
-
List item
List paragraph
-
List item
List paragraph
- Subitem
- Subitem
List paragraph
- Code within list items: indention requires blank line then 4 additional spaces beyond list indention level.
-
Top level
System.out.println("Code fence");Inline:
System.out.println("Inline");
- Blockquote within list items: blank line then indent 4 spaces.
- Top level
Quote is indented.
Markdown Escapes
\ ` * _ { } [ ] ( ) # + - . !
Tables
| Syntax | Whatever |
|---|---|
| Title | Title |
| Title | Title |
Strikethrough
~~Incorrect~~
Spoilers
- Create a spoiler with
>!:
Tyler Durden is Luke Skywalker’s father.
Keyser Söze was dead the whole time.
Allowed HTML
Only some basic HTML elements are whitelisted. Also, only some attributes within those tags are whitelisted as well. If specified, they must be in order! Those that don't meet these requirements are completely stripped from the content.
-
<a>:hrefthentitle -
<b>or<strong>: no attributesBold and Strong
-
<blockquote>: no attributesTo be or not to be, that is the question.
-
<br>: no attributesYou can
break to
the next line. -
<del>or<strike>: no attributesThat's not right.That's not even wrong.Correct. -
<dl>,<dt>, and<dd>: no attributes- SO
- Stack Overflow
- SE
- Stack Exchange
-
<em>or<i>: no attributesEmphasis and Italic
-
<h1>,<h2>, and<h3>: no attributesHeader One
Header Two
Header Three
Header Four
Header Five
Header Six
-
<hr>: no attributes
-
<img>:srcthenwidththenheightthenaltthentitle
-
Specifying one of
widthorheightscales the image; must specify both to change the aspect ratio. They can't bepxand they max out at 999.
-
Animated gifs are supported
-
-
-
<kbd>: no attributesabcdefghijklmnopqrstuvwxyz!@#$%^&*()-_=+`~[{]}|;:'",<.>/?0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
-
Nested
<kbd>elements are allowed.OuterNested
-
-
<ol>or<ul>with<li>:<ol>can havestart<ol><li>First</li><li>Second</li></ol> <ul><li>Something</li><li>Else</li></ul>- First
- Second
- Something
- Else
-
Start at desired number up to 231 - 1.
<ol start="2147483647"><li>First</li></ol>- First
-
<p>: no attributes<p>Paragraph1</p><p>Paragraph2</p>Paragraph1
Paragraph2
-
<pre>: no attributes<pre>System.out.println("Hello World!");</pre>System.out.println("Hello World!"); -
<sup>and<sub>: no attributesx<sup>2</sup> + A<sub>0</sub>x2 + A0
-
They can be nested.
a<sup>b<sup>c<sup>d<sub>e<sup>f</sup></sub></sup></sup></sup>abcdef
-
-
Escape your
<>HashMap<String, Object>HashMap<String, Object>
`HashMap<String, Object>`HashMap<String, Object>HashMap<String, Object>HashMap<String, Object>
Unicode
Emojis
☺🐉
Right-to-left
ABCDEF
Superscript, subscript, strikeout
ᵃᵉⁱᵒᵘ ₐₑᵢₒᵤ s̶t̶r̶i̶k̶e̶o̶u̶t̶
Zalgo
Z̸̧̦̥͔̻̞̟͔͒̓̄̓͐͆͋̃̅͆̓͘̚͝͝à̷̛̜͇̺̖̯̭͓̱̱̣̺̲̪̰l̷̢̳̤̮͈͎̩̱̳̱̱̞͆͂̽̀̃͒̿̄̅͊͘͘̚͠͝ͅg̷͙͋o̶̧̩̓̓͌̄͊͐̓̇̏͝ ̶̛͚͖͍̦͕̞͈͆̋̓̈̏̈̓̊̅͆͘͜t̸̬̮̖̖͙͔̮͊̔͊͌́̈́͒̇͒̽̑̎̚̕͠ė̶̖̰̬͙͙̇̈͌͘͜͜x̴͔̎t̶̖́̒̏͒͌̈́̏͊̒̉ͅ ̵̨͍̬͔̼̣̘̖͍͖̘͍͋̑͛̂̾̋ḧ̸̡̘̬̲̣̺́́̿̀̈ͅé̷̦̰̻̤̲̺̠̏͒̉͛̍͌̍ͅr̶̩̯̱̜͆̌̾͌̑̇̊͒̃̀̽̍̚é̴̜̉̇̿̈́͌̕.̸̢̱͔̲̫̇͌̽̌͂͊͊̈́̇
Sizing
Section titled SizingSmall
Section titled SmallIn ancilliary content like comments or side-discussions, it may be appropriate to add the small variation.
<div class="s-prose s-prose__sm">
…
</div>
Stacks adds a new s-prose class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
<article class="s-prose">
<h1>Garlic bread with cheese: What the science tells us</h1>
<p>
For years parents have espoused the health benefits of eating garlic bread with cheese to their
children, with the food earning such an iconic status in our culture that kids will often dress
up as warm, cheesy loaf for Halloween.
</p>
<p>
But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
springing up around the country.
</p>
<!-- ... -->
</article>
What to expect from here on out
What follows from here is just a bunch of absolute nonsense we’ve written to dogfood the component itself. It includes every sensible typographic element we could think of, like bold text, unordered lists, ordered lists, code blocks, block quotes, and even italics.
It’s important to cover all of these use cases for a few reasons:
- We want everything to look good out of the box.
- Really just the first reason, that’s the whole point of the plugin.
- Here’s a third pretend reason though a list with three items looks more realistic than a list with two items.
Now we’re going to try out another header style.
Typography should be easy
So that’s a header for you—with any luck if we’ve done our job correctly that will look pretty reasonable.
Something a wise person once told me about typography is:
Typography is pretty important if you don’t want your stuff to look like trash. Make it good then it won’t be bad.
It’s probably important that images look okay here by default as well:
Now I’m going to show you an example of an unordered list to make sure that looks good, too:
- So here is the first item in this list.
- In this example we’re keeping the items short.
- Later, we’ll use longer, more complex list items.
And that’s the end of this section.
What if we stack headings?
We should make sure that looks good, too.
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
When a heading comes after a paragraph …
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let’s see what a more complex list would look like.
-
I often do this thing where list items have headings.
For some reason I think this looks cool which is unfortunate because it’s pretty annoying to get the styles right.
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn’t write this way.
-
Since this is a list, I need at least two items.
I explained what I’m doing already in the previous list item, but a list wouldn’t be a list if it only had one item, and we really want this to look realistic. That’s why I’ve added this second list item so I actually have something to look at when writing the styles.
-
It’s not a bad idea to add a third item either.
I think it probably would’ve been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
Code should look okay by default.
Here’s what a default tailwind.config.js file looks like at the time of writing:
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
}
Hopefully that looks good enough to you.
What about nested lists?
Nested lists basically always look bad which is why editors like Medium don’t even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
- Nested lists are rarely a good idea.
- You might feel like you are being really “organized” or something but you are just creating a gross shape on the screen that is hard to read.
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
- Nesting tons of folders in your source code is also not helpful.
- Since we need to have more items, here’s another one.
- I’m not sure if we’ll bother styling more than two levels deep.
- Two is already too much, three is guaranteed to be a bad idea.
- If you nest four levels deep you belong in prison.
- Two items isn’t really a list, three is good though.
- Again please don’t nest lists if you want people to actually read your content.
- Nobody wants to look at this.
- I’m upset that we even have to bother styling this.
The most annoying thing about lists in Markdown is that <li> elements aren’t given a child <p> tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
-
For example, here’s another nested list.
But this time with a second paragraph.
- These list items won’t have
<p>tags - Because they are only one line each
- These list items won’t have
-
But in this second top-level list item, they will.
This is especially annoying because of the spacing on this paragraph.
-
As you can see here, because I’ve added a second line, this list item now has a
<p>tag.This is the second line I’m talking about by the way.
-
Finally here’s another list item so it’s more like a list.
-
-
A closing list item, but with no nested list, because why not?
And finally a sentence to close off this section.
There are other elements we need to style
I almost forgot to mention links, like Stack Overflow.
We even included table styles, check it out:
| Wrestler | Origin | Finisher |
|---|---|---|
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor’s Edge |
We also need to make sure inline code looks good, like if I wanted to talk about <span> elements.
Sometimes I even use code in headings
Another thing I’ve done in the past is put a code tag inside of a link, like if I wanted to tell you about the stackexchange/stacks repository.
We still need to think about stacked headings though.
Let’s make sure we don’t screw that up with h4 elements, either.
Phew, with any luck we have styled the headings above this text and they look pretty good.
We should also make sure we're styling h5 elements as well.
Let’s add a closing paragraph here so things end with a decently sized block of text. I can’t explain why I want things to end that way but I have to assume it’s because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
And, finally, an h6.
Ultimately, though, we also want to support the h6 headers.
What I’ve written here is probably long enough, but adding this final sentence can’t hurt.