英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论