Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1 class="center">Random math formulas</h1>
<p class="center">Someone devs use MathJax, some use MathML<br>But plain HTML + CSS is enougth for good looking formulas</p>
<hr>
<div class="math showcase">
  x = <span class="frac">
    <span> - b &pm; <span class="sqrt">b<sup>2</sup> - 4ac</span></span>
    <span>2a</span>
  </span>
  <span class="annot">sqrt() was hard</span>
</div>

<div class="math showcase">
  braces = 
  <span class="surround round"><span class="frac"><span>round</span><span>is usual</span></span></span> + 
  <span class="surround square"><span class="frac"><span>square</span><span>matrix?</span></span></span> + 
  <span class="surround curly"><span class="frac"><span>curly</span><span>much better</span></span></span>
  <span class="annot">(:</span>
</div>

<div class="math showcase">
  <span class="cs">
    <sup>n</sup>
    <span class="big">∑</span>
    <sub>i = 0</sub>
  </span>
  i<sup>3</sup>
  = <span class="surround round"><span class="frac"><span>n(n+1)</span><span>2</span></span></span>
  <span class="annot">Sum</span>
</div>

<div class="math showcase">
  <span class="arrow">vector</span> = <span class="surround round vec"><span>1</span><span>2</span><span>-3</span></span>
  <span class="annot">Classic pseudo elem arrow</span>
</div>

<div class="math showcase">
  matrix = <span class="surround square matrix" style="--c: 3">
    <span>1</span><span>2</span><span>3</span>
    <span>4</span><span>5</span><span>6</span>
    <span>7</span><span>8</span><span>9</span>
  </span>
  <span class="annot">display: grid</span>
</div>

<div class="math showcase">
  <span class="surround sys matrix" style="--c: 5">
    <span>3x</span><span>+</span><span>5y</span><span>=</span><span>3</span>
    <span>7z</span><span>-</span><span>42x</span><span>=</span><span>6</span>
    <span>33y</span><span>-</span><span>z</span><span>=</span><span>9</span>
  </span>
  <span class="annot">...easy</span>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@200;400&display=swap');
/* @import url('https://fonts.googleapis.com/css2?family=Vollkorn&display=swap');
/*https://fonts.gstatic.com/l/font?kit=BngbUXZYTXPIvIBgJJSb6s3BzlRRfKOFbvjoDISWbXZCW_uI-uaRQWEFwaRKkYmcMi91UqFKWZBmQvGh_gLqDegFSFuY&skey=a9ad6a4717e923f0&v=v16*/

@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@200;400&display=swap&text=∑');

body {
  background: #263238;
  color: #B0BEC5;
  font-family: 'Roboto Slab', serif;
}

h1 {
  font-weight: 200;
  font-size: 2em;
  color: #c792ea;
}

.center {
  text-align: center;
}

hr {
  width: 200px;
  border: 1px solid #2E3C43;
  position: relative;
  margin: 50px auto;
}

hr::before {
  content: '***';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px;
  background: #263238;
  display: block;
  color: #607D8B;
}

.showcase {
  padding: 15px;
  text-align: center;
  position: relative;
}

.math {
  font-family: 'Roboto Slab', serif;
}

.math .small {
  font-size: 0.7em;
}

.math .frac {
  display: inline-flex;
  vertical-align: middle;
  flex-direction: column;
  text-align: center;
  margin-top: -1px;
}

.math .frac > *:first-child {
  border-bottom: 2px solid currentColor;
  padding-bottom: 5px;
}

.math .frac > *:last-child {
  padding-top: 5px;
}

.math .frac > * {
  padding: 0 0.5em;
}

.math .sqrt {
  border-top: 2px solid currentColor;
  margin-left: 10px;
  padding-left: 5px;
  position: relative;
  display: inline-block;
}

.math .sqrt::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -10px;
  bottom: 0px;
  width: 10px;
  background: currentColor;
  clip-path: polygon(
    0 50%,
    2px 50%,
    50% calc(100% - 2px),
    calc(100% - 2px) 0,
    100% 0,
    100% 2px,
    calc(50% + 2px) 100%,
    calc(50% - 2px) 100%,
    0 calc(50% + 2px)
  );
}

.surround {
  padding: 0 10px;
  position: relative;
  display: inline-block;
  --round: 5px;
  --off: 0;
}

.surround::before {
  content: '';
  width: 5px;
  position: absolute;
  top: 0px;
  left: var(--off);
  bottom: 0px;
  width: 5px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-top-left-radius: var(--round);
  border-bottom-left-radius: var(--round);
}

.surround::after {
  content: '';
  width: 5px;
  position: absolute;
  top: 0px;
  right: var(--off);
  bottom: 0px;
  width: 5px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-top-right-radius: var(--round);
  border-bottom-right-radius: var(--round);
}

.surround.round {
  --round: 10px 30px;
}

.surround.square {
  --round: 0;
}

.surround.curly {
  --round: 10px;
  --off: 5px;
  padding: 0 15px;
  background-image: 
    linear-gradient(0deg, currentColor 25%, currentColor 25%),
    linear-gradient(0deg, currentColor 25%, currentColor 25%);
  background-repeat: no-repeat;
  background-size: 5px 2px;
  background-position: 0 center, 100% center;
}

.surround.sys {
  --round: 10px;
  --off: 5px;
  padding: 0 15px;
  background-image: 
    linear-gradient(0deg, currentColor 25%, currentColor 25%);
  background-repeat: no-repeat;
  background-size: 5px 2px;
  background-position: 0 center;
}

.surround.sys::after {
  content: unset;
}

.cs {
  position: relative;
  display: inline-block;
}

.cs > sup {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 50%;
  transform: translate(-50%);
  width: max-content;
}

.cs > sub {
  position: absolute;
  top: calc(100% - 5px);
  left: 50%;
  transform: translate(-50%);
  width: max-content;
}

.big {
  font-size: 2em;
  font-weight: 200;
}

.arrow {
  position: relative;
}

.arrow::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
}

.arrow::after {
  content: '';
  position: absolute;
  bottom: calc(100% - 1px);
  right: -1px;
  height: 5px;
  width: 5px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform-origin: top right;
  transform: rotate(45deg);
}

.surround.vec {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
}

.matrix {
  display: inline-grid;
  grid-template-columns: repeat(var(--c), 1fr);
  grid-gap: 5px;
  padding: 5px 15px;
  vertical-align: middle;
}

.annot {
  color: #607D8B;
  position: absolute;
  right: 15px;
  top: calc(50% - 0.5em);
}
              
            
!

JS

              
                
              
            
!
999px

Console