Markdown Basics
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 13 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Lesson: Mastering Markdown for GitHub
Introduction: Why Markdown Matters in Software Development
In the world of software development, writing code is only half the battle. The other, equally critical half is documenting that code so that others—or your future self—can understand what it does, why it was written, and how to use it. This is where Markdown comes into play. Markdown is a lightweight markup language with plain-text formatting syntax designed to be converted into HTML. Because it is readable as plain text, it is the industry standard for documentation on platforms like GitHub.
When you contribute to a repository on GitHub, you will encounter Markdown everywhere. It powers your README.md files, which serve as the front door to your projects. It is used in pull request descriptions, issue tracking, project wikis, and even within the comments of your code reviews. If you cannot format your thoughts clearly, your technical contributions may be ignored or misunderstood. Mastering Markdown is not just about making things look pretty; it is about clear communication and professional collaboration.
By the end of this lesson, you will understand how to structure documents, manage lists, link to external resources, include code snippets, and organize complex data tables. We will cover the syntax from the ground up, ensuring you have a solid foundation to handle any documentation task you encounter in a professional developer environment.
Not read yet
The Philosophy of Plain Text
Before diving into the syntax, it is helpful to understand the philosophy behind Markdown. Unlike a Word document or a Google Doc, which relies on a complex, proprietary file format that hides formatting data under the hood, Markdown is just characters in a text file. If you open a Markdown file in a simple text editor like Notepad or Vim, you can read the content perfectly well without any special software.
This portability is why it is the preferred format for version control systems like Git. Because Markdown files are plain text, Git can track changes to them line-by-line. When you edit a Word document, Git cannot tell you which specific sentence changed; it can only tell you that the binary file is different. With Markdown, you get precise diffs, allowing you to see exactly who changed a header, a link, or a line of code.
Callout: Markdown vs. Rich Text Editors Markdown is fundamentally different from a "What You See Is What You Get" (WYSIWYG) editor like Microsoft Word. In Word, you highlight text and click a "Bold" button, which inserts invisible formatting tags into the file. In Markdown, you type
**bold**to achieve the same result. While it takes a moment to get used to the syntax, the advantage is that you never have to worry about formatting breaking or fighting with an editor's auto-correction features.
Not read yet
Basic Formatting: Headers, Emphasis, and Paragraphs
The most common tasks you will perform in Markdown are structuring your document with headers and emphasizing specific words or phrases. Markdown uses the hash symbol (#) to denote headers. The number of hashes corresponds to the level of the header, with one hash being the highest level (the page title) and six hashes being the lowest.
Headers
To create a header, place one or more hashes at the beginning of a line, followed by a space. You should always include a space between the hash and the text to ensure it renders correctly across all Markdown parsers.
# This is an H1 Header (Main Title)
## This is an H2 Header (Section)
### This is an H3 Header (Subsection)
#### This is an H4 Header (Minor Heading)
Emphasis
Emphasis is used to draw attention to specific words. You can make text bold or italicized using asterisks or underscores. The standard convention is to use asterisks for consistency.
- Bold: Wrap the text in double asterisks:
**text** - Italic: Wrap the text in single asterisks:
*text* - Bold and Italic: Wrap the text in triple asterisks:
***text***
Tip: You can also use underscores (
_) instead of asterisks for italics and bold, but it is generally recommended to stick to one style throughout your project to maintain consistency. Most developers prefer the asterisk syntax as it is highly visible.
Paragraphs
Paragraphs are the most basic unit of Markdown. To create a paragraph, simply type your text and separate it from other blocks with a blank line. If you do not include a blank line, some parsers will merge the lines together, which might not be the visual result you intended.
Not read yet
Lists: Organizing Information
Lists are essential for breaking down complex information into digestible chunks. GitHub supports both ordered (numbered) and unordered (bulleted) lists.
Unordered Lists
You can create an unordered list using a dash (-), an asterisk (*), or a plus sign (+). Just like with headers, ensure there is a space after the symbol.
- Item one
- Item two
- Item three
Ordered Lists
Ordered lists are created by typing a number followed by a period. Interestingly, Markdown does not care if you use the correct number sequence in your source file; it will render the list starting from 1 sequentially.
1. First step
2. Second step
3. Third step
Nested Lists
You can create nested lists by indenting the items with two or four spaces. This is incredibly useful for creating sub-sections within your documentation.
- Project Requirements
- Node.js installed
- Git configured
- API Key generated
- Project Setup
- Clone the repository
- Run `npm install`
Not read yet
Links and Images
Documentation is rarely a static document; it often needs to point to other resources, such as API documentation, external websites, or project assets.
Links
The syntax for a link consists of the link text in square brackets followed by the URL in parentheses.
[Click here to visit the GitHub documentation](https://docs.github.com)
If you want to create a link that displays the URL directly, you can wrap it in angle brackets: <https://github.com>.
Images
Images follow the same syntax as links, but with an exclamation mark prefix. The text inside the square brackets serves as the "alt text," which is crucial for accessibility and displays if the image fails to load.

Warning: Be careful when linking to images. If the image is hosted on an external server and that server goes down, your documentation will have broken links. For project-specific assets, it is best practice to store the images inside your repository and use relative paths.
Not read yet
Blockquotes and Horizontal Rules
When you need to emphasize a specific point or provide an aside, blockquotes are the perfect tool. They are created using the > character.
> **Note:** Always remember to pull the latest changes before starting a new feature branch.
Horizontal rules are used to create a thematic break between sections. You can create one by placing three or more dashes, asterisks, or underscores on a line by themselves.
---
Code Blocks: The Developer's Best Friend
Since GitHub is a platform for code, the ability to format code snippets is arguably the most important feature of Markdown. There are two ways to format code: inline and block.
Inline Code
Use a single backtick (`) to format text as code within a sentence. This is useful for referencing filenames, command-line arguments, or function names.
Example: "Run the npm start command to launch the local server."
Fenced Code Blocks
For longer snippets, use fenced code blocks. These start and end with three backticks on their own lines. You can also specify the programming language after the first set of backticks to enable syntax highlighting.
function greet(name) {
console.log("Hello, " + name);
}
Syntax highlighting makes your code significantly easier to read. GitHub supports hundreds of languages, including Python, Ruby, JavaScript, Go, and SQL. If you are unsure of the language, you can leave the tag blank, but specifying it is a best practice.
Not read yet
Tables: Managing Data
Tables are a bit more complex in Markdown, but they are essential for comparing features or listing configuration options. A table consists of a header row, a separator row, and data rows.
| Feature | Support | Status |
|---|---|---|
| Markdown | Yes | Active |
| HTML | Yes | Limited |
| CSS | No | N/A |
How to build a table:
- Create a row of headers separated by pipes (
|). - Create a separator row using dashes and pipes. Use colons (
:) to align the text (left, center, or right). - Add your data rows.
The colon placement determines alignment:
:---(Left align):---:(Center align)---:(Right align)
Callout: The Complexity of Tables Tables are the most "fragile" part of Markdown. They are sensitive to spacing and pipe placement. While they are great for simple data, they are not suitable for complex layouts. If you find yourself needing to create a table with many columns or nested data, it is often better to provide a link to a CSV file or a dedicated documentation page.
Not read yet
Best Practices for GitHub Documentation
Now that you know the syntax, it is time to talk about how to write effective documentation. Writing for a developer audience requires a different approach than writing for a general audience.
1. Keep it Concise
Developers are busy. They want the information they need as quickly as possible. Use short paragraphs, clear headers, and bulleted lists to make your document scannable. Avoid long, rambling introductions.
2. Use Meaningful File Names
Your main documentation file should always be named README.md (capitalized). GitHub automatically renders this file on the main page of your repository. If you have additional documentation, use descriptive names like CONTRIBUTING.md, INSTALL.md, or LICENSE.md.
3. Provide Examples
Whenever you describe a feature, provide a code example. Abstract explanations are rarely as useful as a concrete snippet that a user can copy and paste.
4. Use Relative Links
If you are linking to other files within your repository, use relative paths (e.g., ./docs/setup.md) rather than absolute URLs. This ensures that your links continue to work even if you change your repository URL or move it to a different organization.
5. Check for Accessibility
Always use alt text for images. This helps users who rely on screen readers and ensures that the information is still conveyed if an image fails to load.
Not read yet
Common Pitfalls and How to Avoid Them
Even experienced developers make mistakes when writing Markdown. Here are some of the most common issues and how to solve them.
The "Missing Blank Line" Problem
Many developers forget that Markdown parsers often require a blank line to separate blocks. If you write:
# Header
Paragraph text.
The paragraph might be rendered as part of the header or simply look cramped. Always use a blank line between headers and paragraphs, or between lists and text.
Incorrect Indentation
Indenting lists is a common source of frustration. If you want to nest a sub-list, you must use at least two or four spaces. If you use one space, the parser might not recognize it as a nested list, or it might treat it as a separate paragraph.
Hard Wrapping
Some people like to limit their line length to 80 characters for readability in text editors. While this is great for code, it can sometimes cause issues in Markdown if you aren't careful. If you press "Enter" in the middle of a sentence, some parsers will render that as a line break, while others will treat it as a space. If you want to force a line break, add two spaces at the end of the line before pressing enter.
Over-complicating with HTML
Markdown supports raw HTML. While this can be useful for things like colored text or specific layouts, try to avoid it. If you use too much HTML, you lose the primary benefit of Markdown—its simplicity. If your documentation is so complex that it requires HTML, you might want to consider using a static site generator like Jekyll or Hugo.
Not read yet
Quick Reference Table: Markdown Syntax
| Element | Syntax |
|---|---|
| H1 Header | # Text |
| H2 Header | ## Text |
| Bold | **Text** |
| Italic | *Text* |
| Link | [Text](URL) |
| Image |  |
| Unordered List | - Item |
| Ordered List | 1. Item |
| Inline Code | `Code` |
| Code Block | ```Language ... ``` |
| Horizontal Rule | --- |
A Practical Workflow for Writing Documentation
To truly master Markdown, you should integrate it into your daily development workflow. Here is a step-by-step guide on how to approach writing a README.md file for a new project.
Step 1: Define the Purpose
Before you write a single line, ask yourself: "Who is this for?" If it's for other developers, focus on setup, dependencies, and testing. If it's for end-users, focus on installation and basic usage.
Step 2: Create a Structure
Use headers to create a logical flow. A standard README.md structure looks like this:
- Project Title
- Description (The "Why")
- Installation
- Usage
- Contributing
- License
Step 3: Write the Content
Start filling in your headers. Keep sentences short and direct. Use code blocks for commands.
Step 4: Preview Before Committing
GitHub provides a "Preview" tab in the file editor. Always click this tab to see how your document renders before you commit your changes. This is the best way to catch formatting errors.
Step 5: Test Your Links
Click on every link you have added. It is surprisingly easy to make a typo in a URL. A broken link in a README.md reflects poorly on the quality of your code.
Not read yet
Advanced Markdown Tips
Once you are comfortable with the basics, there are a few "pro-level" features that can make your documentation even better.
Task Lists
GitHub allows you to create task lists, which show up as checkboxes in the UI. This is incredibly helpful for tracking progress on a project.
- [x] Research the API
- [ ] Implement the authentication module
- [ ] Write unit tests
Emoji Support
While you should not use them in formal technical documentation, emojis can add a friendly touch to project descriptions or status updates. You can type them using colons, like :rocket: or :smile:.
Collapsible Sections
If you have a large amount of information that might clutter the page, you can use the HTML <details> tag to create a collapsible section.
<details>
<summary>Click to see more details</summary>
Here is the extra information that you might not need to see immediately.
</details>
Footnotes
If you need to cite sources, you can use footnotes.
Here is a statement that requires a source [^1].
[^1]: This is the source of the statement.
Not read yet
Common Questions (FAQ)
Q: Can I use Markdown in my code files? A: You can use it in comments, but the code itself is interpreted by the compiler or interpreter, not a Markdown parser. However, many documentation generators (like JSDoc or Doxygen) will parse Markdown inside your code comments to generate documentation websites.
Q: Why does my list formatting look weird?
A: Check your indentation. Ensure that you have a blank line before the list starts, and ensure that all items in the list use the same symbol (e.g., don't mix - and * in the same list).
Q: How do I escape characters?
A: If you need to display a character that has a special meaning in Markdown (like a backtick or a hash), use a backslash (\) before it. For example, \# will display as a literal hash instead of a header.
Q: Is there a specific Markdown flavor used on GitHub? A: Yes, GitHub uses "GitHub Flavored Markdown" (GFM). It is a superset of standard Markdown that adds features like task lists, tables, and automatic linking of issues and pull requests.
Not read yet
Key Takeaways
As you wrap up this lesson, keep these core principles in mind:
- Readability is King: The primary goal of Markdown is to be readable as plain text. If your source file is messy and hard to read, your rendered output will likely be confusing as well.
- Consistency Matters: Choose a style for your project—such as using dashes for lists and asterisks for bolding—and stick to it throughout all your files.
- Preview Before You Commit: Always use the GitHub "Preview" tab to verify that your formatting renders as expected. It is a simple step that saves time and prevents embarrassing typos.
- Use Semantic Structure: Use headers for hierarchy, not for visual size. Your document should follow a logical path from top to bottom, making it easy for a reader to understand the structure of the project.
- Leverage Code Blocks: Never put code directly in a paragraph. Always use backticks or fenced code blocks to ensure your code is distinct from your text. This makes it easier for users to copy your examples.
- Keep it Simple: Markdown is designed to be lightweight. If you find yourself struggling with complex layouts, you are likely trying to force Markdown to do something it wasn't intended for.
- Document for the Future: Think of your documentation as a gift to the next person who works on the project. A well-documented project is much more likely to be successful and attract contributors.
By internalizing these practices, you will elevate your technical documentation from a simple side-task to a professional-grade asset that enhances the quality of your software projects. Whether you are writing a small script or a large library, clear documentation is the hallmark of a high-quality developer.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- What is Version Control
- What is Version Control Quiz5q
- Benefits of Version Control
- Benefits of Version Control Quiz5q
- Introduction to Git
- Introduction to Git Quiz5q
- Git vs GitHub Differences
- Git vs GitHub Differences Quiz5q
- Understanding Repositories
- Understanding Repositories Quiz5q
- Commits and Commit History
- Commits and Commit History Quiz5q
- Branches and Branching Strategies
- Branches and Branching Strategies Quiz5q
- GitHub Accounts and Profiles
- GitHub Accounts and Profiles Quiz5q
- GitHub Organizations
- GitHub Organizations Quiz5q
- GitHub Enterprise Options
- GitHub Enterprise Options Quiz5q
- GitHub Flow for Collaboration
- GitHub Flow for Collaboration Quiz5q
- Markdown Basics
- Markdown Basics Quiz5q
- GitHub Desktop Application
- GitHub Desktop Application Quiz5q
- GitHub Mobile
- GitHub Mobile Quiz5q
- Repository Structure Overview
- Repository Structure Overview Quiz5q
- README Files Best Practices
- README Files Best Practices Quiz5q
- LICENSE Files and Open Source
- LICENSE Files and Open Source Quiz5q
- CONTRIBUTING Guidelines
- CONTRIBUTING Guidelines Quiz5q
- CODEOWNERS File
- CODEOWNERS File Quiz5q
- SECURITY Policy Files
- SECURITY Policy Files Quiz5q
- Creating Repositories
- Creating Repositories Quiz5q
- Repository Templates
- Repository Templates Quiz5q
- Managing Files in Repositories
- Managing Files in Repositories Quiz5q
- Repository Insights and Metrics
- Repository Insights and Metrics Quiz5q
- Stars and Feature Previews
- Stars and Feature Previews Quiz5q
- Dependency Insights
- Dependency Insights Quiz5q
- Introduction to Issues
- Introduction to Issues Quiz5q
- Pull Requests Fundamentals
- Pull Requests Fundamentals Quiz5q
- GitHub Discussions
- GitHub Discussions Quiz5q
- Linking PRs to Issues
- Linking PRs to Issues Quiz5q
- Issue and PR Templates
- Issue and PR Templates Quiz5q
- Filters and Assignments
- Filters and Assignments Quiz5q
- Introduction to GitHub Actions
- Introduction to GitHub Actions Quiz5q
- GitHub Actions Components
- GitHub Actions Components Quiz5q
- Introduction to GitHub Copilot
- Introduction to GitHub Copilot Quiz5q
- Copilot Agents and Agent Mode
- Copilot Agents and Agent Mode Quiz5q
- Multi-Model Support in Copilot
- Multi-Model Support in Copilot Quiz5q
- Copilot Plans Comparison
- Copilot Plans Comparison Quiz5q
- Introduction to GitHub Projects
- Introduction to GitHub Projects Quiz5q
- Project Layout Options
- Project Layout Options Quiz5q
- Configuring Projects
- Configuring Projects Quiz5q
- Labels and Milestones
- Labels and Milestones Quiz5q
- Project Workflows
- Project Workflows Quiz5q
- Saved Replies and Assignees
- Saved Replies and Assignees Quiz5q
- Project Insights and Analytics
- Project Insights and Analytics Quiz5q
- Two-Factor Authentication
- Two-Factor Authentication Quiz5q
- Passkeys for Authentication
- Passkeys for Authentication Quiz5q
- Repository Access Permissions
- Repository Access Permissions Quiz5q
- Organization Roles
- Organization Roles Quiz5q
- Enterprise Managed Users
- Enterprise Managed Users Quiz5q
- Copilot Policy Management
- Copilot Policy Management Quiz5q
- Benefits of Open Source
- Benefits of Open Source Quiz5q
- GitHub Sponsors
- GitHub Sponsors Quiz5q
- Supporting Open Source Projects
- Supporting Open Source Projects Quiz5q
- Following Users and Organizations
- Following Users and Organizations Quiz5q
- GitHub Marketplace
- GitHub Marketplace Quiz5q
- InnerSource Principles
- InnerSource Principles Quiz5q
Spend your points to unlock exam-style practice questions
Spend points to unlock GH-900 exam-style practice questions.
Practice for GH-900