Setting text alignment to justify in .md file works in VS Code but not in GitHub

huangapple go评论53阅读模式
英文:

Setting text alignment to justify in .md file works in VS Code but not in GitHub

问题

I'm trying to set the text alignment of my README.md file to justify. I tried the following in VS Code and the preview showed exactly what I wanted.

<p style="text-align: justify;">
My paragraph
</p>

But when I pushed it to GitHub, I saw that this line of code did not change alignment. I searched a little more and came up with this solution:

<p align="justify"> 
My paragraph
</p>

And it worked on GitHub (and VS Code). My question is, what's the difference between GitHub and VS Code here? Why doesn't the first solution work for GitHub?

英文:

I'm trying to set the text alignment of my README.md file to justify. I tried the following in VS Code and the preview showed exactly what I wanted.

<p style="text-align: justify;">
My paragraph
</p>

But when I pushed it to GitHub, I saw that this line of code did not change alignment. I searched a little more and came up with this solution:

<p align="justify"> 
My paragraph
</p>

And it worked on GitHub (and VS Code). My question is, what's the difference between GitHub and VS Code here? Why doesn't the first solution work for GitHub?

答案1

得分: 1

我认为第一个解决方案在GitHub上不起作用,是因为GitHub的Markdown解析器不支持使用内联样式,如style="text-align: justify"。内联样式通常用于在HTML中为特定元素应用样式,但在Markdown中,最好使用一种更通用的方法,以便在所有平台上都受支持。

'align'是一个标准的HTML属性,得到广泛支持,包括GitHub的Markdown解析器。

英文:

I think first solution didn't work on GitHub is because GitHub's Markdown parser does not support using inline styles like style="text-align: justify;". Inline styles are often used in HTML to apply styling to a specific element, but in Markdown, it's better to use a more universal approach that is supported across all platforms.

'align' is a standard HTML attribute that is widely supported, including by GitHub's Markdown parser

huangapple
  • 本文由 发表于 2023年2月19日 16:50:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498972.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定