css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <script type="text/javascript">
  window.MathJax = {
    jax: ["input/TeX", "output/CommonHTML"],
    extensions: ["tex2jax.js"],
    TeX: {
      equationNumbers: { autoNumber: "AMS" },
      extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
    /* The MathJax API provides us with the ability to register
    callbacks on signals broadcast during its startup sequence.
    https://docs.mathjax.org/en/v1.1-latest/startup.html */
    AuthorInit: function() {
      MathJax.Hub.Register.StartupHook("End Typeset", function() {
        const fullFontSize = 121;
        var renderMath = function() {
          /* All formulae that we want to enable responsive scaling
          for need to be wrapped with `class="mj-formula"` */
          var mjFormulae = document.getElementsByClassName("mj-formula");
          if (mjFormulae) {
            for (var i = 0; i < mjFormulae.length; ++i) {
              var mjFormula = mjFormulae[i];

              /* Retrieve the MathJax element `MathJax_CHTML`. If this element
              has a descendant `mjx-table`, the element is a multi-line equation
              with automatic numbering and its scaling factor has to be calculated
              differently. Note: if your output processor is not `CommonHTML`, I
              suspect these class names may be different */
              var mjElement = mjFormula.getElementsByClassName("MathJax_CHTML")[0];
              var mjTable = mjElement.getElementsByClassName("mjx-table")[0];

              /* If the equation is single-line, the scaling factor is a function
              of `MathJax_CHTML`'s offset width. If it's multi-line, it is a
              function of its descendant `mjx-table` */
              var scale = 0.8 * (mjTable ?
                mjFormula.offsetWidth / mjTable.offsetWidth :
                mjFormula.offsetWidth / mjElement.offsetWidth);

              /* Apply the scaling factor to the old font size, rounded to the
              nearest integer, as long as it does not exceed the max font size */
              const oldFontSize = parseInt(mjElement.style.fontSize);
              var newFontSize = Math.round(Math.min(oldFontSize * scale, fullFontSize));
              mjElement.style.fontSize = `${newFontSize}%`;

        /* `renderMath` needs to be called once on the `End Typeset`
        signal broadcast so the scaling is applied on first load */

        /* Attach an event handler that calls `renderMath` after a small delay */
        var timeoutId;
        const delay = 250;
        window.addEventListener("resize", function() {
          timeoutId = setTimeout(renderMath, delay);

  <div class="container">
    <div class="content">
      <div class="mj-formula">
        $$ (1+x)^n = 1 + nx + \frac{n(n-1)}{2!}x^2 + \frac{n(n-1)(n-2)}{3!}x^3 + \frac{n(n-1)(n-2)(n-3)}{4!}x^4 + \ldots $$
      <h4>Numbered multi-line:</h4>
      <div class="mj-formula">
        (1+x)^n &= 1 + nx + \frac{n(n-1)}{2!}x^2 + \frac{n(n-1)(n-2)}{3!}x^3 + \frac{n(n-1)(n-2)(n-3)}{4!}x^4 + \ldots \\
        (1+x)^n &= 1 + nx + \frac{n(n-1)}{2!}x^2 + \frac{n(n-1)(n-2)}{3!}x^3 + \ldots

              body {
  background: black;
  font-family: "Courier New", sans-serif;

.container {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -ms-flex-align: center;
  -webkit-align-items: center;
  -webkit-box-align: center;

  align-items: center;
  height: 100vh;

.content {
  background: white;
  text-align: center;
  width: 80%;
  margin: 0 auto;

  border-radius: 10px;
  padding: 10px;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................