PubChem Widgets

Any section or subsection of PubChem summary or record pages (compounds, elements, substances, bioassays) as well as periodic table can be turned into a widget to be embedded into any web page. See widget examples to get a quick idea of the possibilities.


For instance, below is an IUPAC Name section from compound summary page for aspirin ( embedded into this page as a widget.


To embed a PubChem widget from above example, add the following code to your page at the location where you want the widget to appear:

<iframe class="pubchem-widget" src="" style="width: 100%; height: 300px;"></iframe>


To find the value for the src attribute for the iframe of a PubChem widget, scroll to the section of interest such as and then add "&embed=true" at the end of the URL. Thus, you will have


Note that you can wrap the widget in a container, which can be styled as you like:

<div style="border: solid 1px #ccc; padding: 2px; width: 80%;"><iframe class="pubchem-widget" src="" style="border: 0; width: 100%; height: 300px;"></iframe></div>



Adjusting Widget Size

As shown in examples above, the iframe has to have the width and the height set inside the style attribute.


Setting the Width

It is generally a good idea to set the iframe width parameter to 100%, and if a smaller width is desired, wrap the iframe in a container with a desired width set in the container's style parameter. See the code examples above.


Setting the Height

Setting the iframe height to an optimal value can be more difficult. If the content height exceeds the iframe height, a vertical scrollbar appears in the iframe. On the other hand, if the iframe height is set to a high value, there can be a lot of empty space below the content.


Adjusting Widget Height to Accomodate Content Height

If you would like to avoid vertical scrollbars on the widgets, we provide a method to automatically adjust the widget iframe height to that of the content.

To use this method, add scrolling="no" attribute to the iframe and do not set the height on the iframe or the container as shown below:

<div style="border: solid 1px #ccc; padding: 2px; width: 80%;"><iframe class="pubchem-widget" scrolling="no" src="" style="border: 0; width: 100%;"></iframe></div>


In addition, add the following code (open source iframe resizer) to your page (only once, even if you have multiple pubchem widgets on the page) just before the closing body tag:

<script type="text/javascript" src=""></script>


<script type="text/javascript">iFrameResize({log:false,checkOrigin:false}, '.pubchem-widget')</script>


Note that some PubChem page sections can be very long, and thus, it is up to you to decide whether a vertical scrollbar is better suitable for your pages.




Suppressing Record Title

In some cases, when the page prominently includes record title (such as "Tiformin" it might be desirable to leave out the record title from the widget.

To do so, use the option hide_title=true in the iframe src attribute as shown below:

<iframe class="pubchem-widget" src="" style="border: 0;  width: 100%; height: 300px;"></iframe>





What Happens if a Widget Links to a Nonexistent PubChem Record or Record Section?

If the URL provided in the iframe src attribute does not exist in PubChem, the results of what shows up in the iframe might be unpredictable - it could be a 404 page or a search interface depending on what exactly was in the src attribute.

However, if the widget links to a nonexistent section of a valid PubChem record, then the widget will simply display a message saying that the section for that particular record does not exist, see below:





  1. BioAssay Description
  2. BioAssay Data Table
  3. Compound 2D Structure
  4. Compound 3D Conformer
  5. Compound Bioactivities Table
  6. Compound Literature Citations
  7. Compound Patents
  8. Substance Bioactivities Table
  9. Compound Classification
  10. Compound Related Records
  11. Periodic Table
  12. Periodic Table Game
  13. Element Information Card
  14. Element History


Note that this list of examples is not exhaustive and that any section or subsection in the table of contents of Compound Summary or BioAssay/Substance Record pages can be embedded as a widget. However, please keep in mind that some sections might be more useful than others as standalone widgets.



Was this information helpful?


National Library of Medicine
8600 Rockville Pike
Bethesda, MD 20894


PubChem Help
HHS Vulnerability Disclosure


The page cannot be found

The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. Please make sure you spelled the page name correctly or use the search box.