Create sophisticated formatting for your prose and code on GitHub with simple syntax.
In this article:
- Headings
- Styling text
- Quoting text
- Quoting code
- Links
- Section links
- Relative links
- Lists
- Task lists
- Using HTML symbols
- Paragraphs and line breaks
- Ignoring HTML formatting
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>
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> |
||
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 |
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>
To quote text into its own distinct block, use quotation tag.
In the words of Abraham Lincoln:
<blockquote>Pardon my French</blockquote>
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.
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>
For more information, see "Creating and highlighting code blocks".
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>.
You can link directly to a section in a rendered file by hovering over the section heading to expose the link:
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.
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>
To order your list, precede the lines with <ol>
.
<ol>
<li>James Madison</li>
<li>James Monroe</li>
<li>John Quincy Adams</li>
</ol>
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>
For more examples, see the GitHub Flavored Markdown Spec.
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>
For more information, see "About task lists".
You can add HTML symbols to your writing by typing &#number;
or &entity;
.
@octocat 👍 This PR looks great - it's ready to merge!
For a full list of available emoji and codes, check out emoji-cheat-sheet.com.
You can create a new paragraph by tagging text with <p>
, and you can break a line with <br>
.
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\*.
For more information, see Daring Fireball's "Markdown Syntax".