Sub topic 3
Headings, Paragraphs, and Emphasis
This chapter assumes you can edit a file in a GitHub repository and commit it. It also assumes you know what a README is for. Here you will learn the text-structure syntax that every other README feature builds on.
Headings
A heading starts with one to six # characters, then a space, then the text. The number of # characters sets the level.
# Project Name
## Installation
### From sourceUse one # heading as the page title. Use ## for the main sections and ### for subsections. Skipping levels, such as jumping from ## to ####, makes the outline harder to follow for screen reader users and for GitHub's automatic table of contents.
A common error is leaving out the space: #Installation renders as plain text, not as a heading.
GitHub builds a navigation outline from your headings. It also gives each heading an anchor, which later chapters use for links.
Paragraphs and line breaks
A paragraph is one or more lines of text separated from the next block by a blank line. A single newline inside a paragraph does not start a new line in the output. The lines are joined with a space.
This line and
this line render as one paragraph.
This is a second paragraph.To force a line break inside a paragraph, end the line with a backslash or with two spaces. The backslash is easier to see and survives editors that trim trailing whitespace.
First line\
Second lineEmphasis
Emphasis marks change how text looks.
| Syntax | Result | Use for |
|---|---|---|
| `*text*` or `_text_` | italic | Terms and light stress |
| `**text**` or `__text__` | bold | Warnings and key names |
| `***text***` | bold and italic | Rare, strong stress |
| `~~text~~` | strikethrough | Removed or outdated items |
Pick one style and use it consistently. Underscores inside a word, as in snake_case_name, are not treated as emphasis, but asterisks are. If a file name or option contains asterisks, wrap it in backticks.
Do not use bold for whole paragraphs or in place of headings. Bold only helps when it is rare.
How the pieces fit
Exercise
A contributor writes #Usage and two consecutive lines, "Run the tool" and "then check the output". Both render as plain text on one line. What are the two fixes?
Show answer
Add a space to make # Usage, or ## Usage if it is a section. Then either put a blank line between the two lines to make separate paragraphs, or end the first line with a backslash to force a line break.