5

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.

Sebastian Palma
  • 29,105
  • 6
  • 30
  • 48
vancexu
  • 1,348
  • 3
  • 17
  • 26

3 Answers3

18

Try using kramdown block attributes kramdown block attributes :

Test text
{: style="color:gray; font-size: 80%; text-align: center;"}
David Jacquel
  • 46,880
  • 4
  • 106
  • 132
  • 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. – Abhimanyu Shekhawat Jul 22 '20 at 10:01
6

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?

Community
  • 1
  • 1
wordsforthewise
  • 8,361
  • 3
  • 56
  • 90
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>
trigger_segfault
  • 465
  • 4
  • 19