BalaKrishnan웃
BalaKrishnan웃

Reputation: 4557

How to display HTML content in github README.md?

I am new to github, in README.md want to display a HTML content using an Iframe or something is this possible ?

What I have tried is I just create HTML tags other then anchor, that is not working.

Upvotes: 134

Views: 142222

Answers (3)

lazysoundsystem
lazysoundsystem

Reputation: 2169

As answered by mjgpy3, you can include html - no <html> tags needed, but it'll be sanitized before display and the only tags allowed are in this whitelist.

The list currently includes:

  • a
  • abbr
  • b
  • bdo
  • blockquote
  • br
  • caption
  • cite
  • code
  • dd
  • del
  • details
  • dfn
  • div
  • dl
  • dt
  • em
  • figcaption
  • figure
  • h1
  • h2
  • h3
  • h4
  • h5
  • h6
  • h7
  • h8
  • hr
  • i
  • img
  • ins
  • kbd
  • li
  • mark
  • ol
  • p
  • pre
  • q
  • rp
  • rt
  • ruby
  • s
  • samp
  • small
  • span
  • strike
  • strong
  • sub
  • summary
  • sup
  • table
  • tbody
  • td
  • tfoot
  • th
  • thead
  • time
  • tr
  • tt
  • ul
  • var
  • wbr

but no iframe.

Upvotes: 63

yihao ye
yihao ye

Reputation: 431

You can use svg to work around, example code (./path/example.svg):

<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<foreignObject width="100" height="100">
    <div xmlns="http://www.w3.org/1999/xhtml">
        <ul>
            <li>text</li>
        </ul>
        <!-- Other embed HTML element/text into SVG -->
    </div>
</foreignObject>
</svg>

and then use image insert way to embed the svg file in any other markdown file, like this:

![](./path/example.svg)

Upvotes: 25

mjgpy3
mjgpy3

Reputation: 8947

Github's markdown interpreter can include HTML. However, there is only so much you can do in HTML. I would suggest checking out this article which provides more information on what tags can be used. Personally, I have never used much more than line-breaks, horizontal rules, etc... Unfortunately, I don't see Iframes mentioned in the article.

Upvotes: 67

Related Questions