Skip to content

Instantly share code, notes, and snippets.

@kvpb
Last active July 27, 2022 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvpb/9a17072df6e3ddfeedf91d616c4dbac1 to your computer and use it in GitHub Desktop.
Save kvpb/9a17072df6e3ddfeedf91d616c4dbac1 to your computer and use it in GitHub Desktop.
HTML counterpart of GitHub's 'Basic writing and formatting syntax' article (https://web.archive.org/web/20180310203106/https://help.github.com/articles/basic-writing-and-formatting-syntax/).

Basic writing and formatting syntax

Create sophisticated formatting for your prose and code on GitHub with simple syntax.

In this article:

Headings

To create a heading, add a <hn> tag around your heading text. The n number, from 1 to 6, of <hn> you use will determine the size of the heading.

<h1>The largest heading</h1>
<h2>The second largest heading</h2>
<h6>The smallest heading</h6>

Rendered H1, H2, and H6 headings

Styling text

You can indicate emphasis with bold, italic, or strikethrough text.

Style Syntax Keyboard shortcut Example Output
Bold <b> or <strong> command/control + b <b>This is bold text</b> This is bold text
Italic <i> or <em> command/control + i <i>This text is italicized</i> This text is italicized
Strikethrough <s>, <strike> or <del> <s>This was mistaken text<s> This was mistaken text
Underline <u> or <ins> <ins>This is underlined text.</ins> This text is underlined
Subscript <sub> <sub>This is subscript text.</sub> This is subscript text.
Superscript <sup> <sup>This is superscript text.</sup> This is superscript text.
Bold and italic <b> or <strong> and <i> or <em> <b>This text is <i>extremely</i> important</b> This text is extremely important

Quoting text

You can quote text within a sentence with a short quotation tag. The text within the short quotation tag will be quoted.

In the words of Abraham Lincoln: <q>Pardon my French</q>

Rendered quoted short text

To quote text into its own distinct block, use quotation tag.

In the words of Abraham Lincoln:

<blockquote>Pardon my French</blockquote>

Rendered quoted text

Quoting code

You can call out code or a command within a sentence with single code tag. The text within the code tag will not be formatted.

Use <code>git status</code> to list all new or modified files that haven't yet been committed.

Rendered inline code block

To format code or text into its own distinct block, use pre and code tags.

Some basic Git commands are:
<pre><code>
git status
git add
git commit
</code></pre>

Rendered code block

For more information, see "Creating and highlighting code blocks".

Links

You can create an inline link by wrapping link text in hyperlink tag <a>, and then wrapping the URL in hyperlink tag's href attribute href="". You can also use the keyboard shortcut command + k to create a link.

This site was built using <a href="https://pages.github.com/">GitHub Pages</a>.

Rendered link

Section links

You can link directly to a section in a rendered file by hovering over the section heading to expose the link:

Section link within the README file for the github/scientist repository

Relative links

You can define relative links and image paths in your rendered files to help readers navigate to other files in your repository.

A relative link is a link that is relative to the current file. For example, if you have a README file in root of your repository, and you have another file in docs/CONTRIBUTING.md, the relative link to CONTRIBUTING.md in your README might look like this:

<a href="docs/CONTRIBUTING.md">Contribution guidelines for this project</a>

GitHub will automatically transform your relative link or image path based on whatever branch you're currently on, so that the link or path always works. You can use all relative link operands, such as ./ and ../.

Relative links are easier for users who clone your repository. Absolute links may not work in clones of your repository - we recommend using relative links to refer to other files within your repository.

Lists

You can make an unordered list by preceding one or more lines of text with <ul> and each line withing with <li>.

<ul>
	<li>George Washington</li>
	<li>John Adams</li>
	<li>Thomas Jefferson</li>
</ul>

Rendered unordered list

To order your list, precede the lines with <ol>.

<ol>
	<li>James Madison</li>
	<li>James Monroe</li>
	<li>John Quincy Adams</li>
</ol>

Rendered ordered list

Nested Lists

You can create a nested list by writing one or more lists within another list.

<ol>
	<li>First list item</li>
	<ul>
		<li>First nested list item</li>
			<ul>
				<li>Second nested list item</li>
			</ul>
	</ul>
</ol>

List with two levels of nested items

For more examples, see the GitHub Flavored Markdown Spec.

Task lists

To create a task list, preface list items with <input type="checkbox" disabled> , and postface each but the last with <br>. To mark a task as complete, use <input type="checkbox" checked disabled> .

<ul>
	<input type="checkbox" checked disabled> Finish my changes<br>
	<input type="checkbox" disabled> Push my commits to GitHub<br>
	<input type="checkbox" disabled> Open a pull request<br>
</ul>

Rendered task list

For more information, see "About task lists".

Using HTML symbols

You can add HTML symbols to your writing by typing &#number; or &entity;.

@octocat &#128077; This PR looks great - it's ready to merge!

Rendered emoji

For a full list of available emoji and codes, check out emoji-cheat-sheet.com.

Paragraphs and line breaks

You can create a new paragraph by tagging text with <p>, and you can break a line with <br>.

Ignoring HTML formatting

You can tell GitHub to ignore (or escape) HTML formatting by using <pre> around the text character.

Let's rename \*our-new-project\* to \*our-old-project\*.

Rendered escaped character

For more information, see Daring Fireball's "Markdown Syntax".

Further reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment