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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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.


                <div class="wrapper">
  <h1>Highlight Within Textarea v2</h1>
  <p>Highlight <input type="text" id="blue-word" value="possible"> in blue and <input type="text" id="pink-word" value="magic"> in pink.</p>
  <textarea spellcheck="false">The two words above are highlighted in this textarea. Such a thing isn't actually possible with HTML, but we can fake it with some CSS and JS magic. Go ahead, type some stuff in here or change the words above to see the real-time highlighting in action.</textarea>



                @import url(',700');

*, *::before, *::after {
  box-sizing: border-box;

html {
  min-height: 100%;

body {
  margin: 0;
  font: 1.5rem 'Asap', sans-serif;
  background-image: linear-gradient(120deg, #9890e3 0%, #b1f4cf 100%);

.wrapper {
  width: 650px;
  margin: 40px auto;
  text-align: center;

h1 {
  margin: 0 0 20px;
  font-size: 2.75rem;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);

p {
  margin: 0 0 40px;

input {
  appearance: none;
  display: inline-block;
  width: 100px;
  padding: 0;
  border: 0;
  border-bottom: 2px dashed #fff;
  border-radius: 0;
  text-align: center;
  font-size: inherit;
  font-family: inherit;
  font-weight: bold;
  background-color: transparent;

.hwt-container {
  background-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);

.hwt-content {
  width: 650px;
  height: 225px;
  padding: 20px;
  border: 1px solid #fff;
  text-align: left;
  font-size: 1.5rem;
  line-height: 1.5;
  mark {
    border-radius: 2px;
    background-color: #fcc2d7;
    box-shadow: 0 0 0 1px #fff;
    &.blue {
      background-color: #a3daff;
    &.pink {
      background-color: #fcc2d7;



                // Uses highlight-within-textarea

function highlightBlue() {
  return $('#blue-word').val();

function highlightPink() {
  return $('#pink-word').val();

function updateHighlights() {

  highlight: [
      highlight: highlightBlue,
      className: 'blue'
      highlight: highlightPink,
      className: 'pink'

$('input').on('input', updateHighlights);