120

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.

mjgpy3
  • 8,597
  • 5
  • 30
  • 51
BalaKrishnan웃
  • 4,337
  • 7
  • 30
  • 51
  • Other suggestions in the duplicate question: https://stackoverflow.com/questions/48402823/embed-openstreetmap-iframe-in-github-markdown – Martin Smith Nov 25 '20 at 09:55

3 Answers3

59

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.

mjgpy3
  • 8,597
  • 5
  • 30
  • 51
  • 21
    They aggressively remove html that could be harmful to users, such as scripts. An iframe would fall under that category because you could potentially serve people anything, even malware right there on github. – s1h4d0w May 20 '16 at 16:39
55

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:

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

but no iframe.

lazysoundsystem
  • 2,039
  • 23
  • 23
  • 1
    lazysoundsystem's posted list Changed, See line # 46,47,48 for ALLOWED HTML TAGs: [GitHub-HTML-pipeline-sanitization_filter.rb](https://github.com/github/html-pipeline/blob/master/lib/html/pipeline/sanitization%5Ffilter%2Erb), I verified+found the link is correct, at this moment. Such TAGs Not-Allowed : script, style, iframe, span,… But div, table,…partially allowed. GitHub also removes/filters many Attributes used inside TAGs. As GitHub can apply Filter on TAGs & Attrib(s), They should allow – atErik Jun 30 '20 at 00:05
17

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)
yihao ye
  • 331
  • 3
  • 4