58

I tried to put some HTML snippets into my README.md on Github but the HTML codes are parsed.

How do I do it?

<h2>Example of code</h2>

<pre>
    <div class="container">
        <div class="block two first">
            <h2>Your title</h2>
            <div class="wrap">
                //Your content
            </div>
        </div>
    </div>
</pre>

1 Answer 1

107

Try putting your HTML snippet inside an ```HTML block like this:

```html
<h2>Example of code</h2>

<pre>
    <div class="container">
        <div class="block two first">
            <h2>Your title</h2>
            <div class="wrap">
            //Your content
            </div>
        </div>
    </div>
</pre>
```
Sign up to request clarification or add additional context in comments.

4 Comments

@tonymx227 It's a feature of the redcarpet library which GitHub uses for Markdown rendering: github.com/vmg/redcarpet. See the "fenced code blocks" option.
@IvanZuzak Thank you - it works for me. It seems you have to make sure you put your HTML is in the second line as you have shown in your example.
awesome! This worked for the markdown plugin in JetBrains IDEs
you can use this ``` ``` to pass any code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.