Jekyll kramdown how to center text
Asked Answered
F

3

11

I am using Jekyll (kramdown), and want to make some text align center.

I found <span style=""> works for font color and size, but not work for text-align.

How can I align some text.

I have tried:

<span style="color:gray; font-size: 80%; text-align: center;">Test Text</span>

And:

-> Test Text <-

None of them work.

Fencer answered 3/2, 2015 at 9:2 Comment(0)
M
27

Try using kramdown block attributes kramdown block attributes :

Test text
{: style="color:gray; font-size: 80%; text-align: center;"}
Mechanistic answered 3/2, 2015 at 11:58 Comment(1)
This was really helpful. While using kramdown, most of the users are not even aware of how powerful it could be. For a long time, I used HTML tags inside markdown to achieve what kramdown could achieve with block attributes.Atony
B
5

You can also just do

<center>This text is centered.  And clean.  Amen.</center>

as I found here: Using Markdown, how do I center an image and its caption?

Berkman answered 11/1, 2016 at 15:5 Comment(2)
It helped! With VIM surround plugin, adding <center> is a breezeWolgast
Note that the <center> tag has been deprecated for many years, so you should probably avoid it. developer.mozilla.org/en-US/docs/Web/HTML/Element/centerDebauch
W
0

Although I also agree that Kramdown is best the way to go, another alternative is to replace your <span> tags with <p> tags.

<p style="color:gray; font-size:80%; text-align:center;">Test Text</p>

<!-- or -->

<p style="color:gray; font-size:80%;" align="center">Test Text</p>
Wivinia answered 11/5, 2019 at 15:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.