10

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.

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
vancexu
  • 1,548
  • 3
  • 19
  • 30

3 Answers3

25

Try using kramdown block attributes kramdown block attributes :

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

Community
  • 1
  • 1
wordsforthewise
  • 13,746
  • 5
  • 87
  • 117
  • It helped! With VIM surround plugin, adding `
    ` is a breeze
    – Anwar Mar 07 '17 at 14:33
  • 2
    Note that the `
    ` tag has been deprecated for many years, so you should probably avoid it. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center
    – Harold Cooper Mar 18 '22 at 20:40
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
  • 554
  • 1
  • 6
  • 23