Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <p>This textarea checks for existence of the word 'link' in each line and shows a hint when linked items exist</br>Add items to the list and scroll!</p>
<div class="lebox">
  <div id="container">
    <div id="divlines">
    </div>
  </div>
  <textarea id="text1" cols="50" wrap="off">
first link
second link
third
fourth link
fifth
sixth
seventh link
eighth
ninth</textarea>
  <span class="errortext">
    ➜ denotes options that include a link
  </span>
</div>
<!-- <button id="reset" onclick="resetText()">Clear</button> -->
              
            
!

CSS

              
                * {
  font-family: Helvetica, Arial;
}
.lebox {
  width: 320px;
  position: relative;
}
#container
{
	width: 20px;
	position: absolute;
	color: DarkBlue;
  font-weight: 900;
	font-size: 14px;
	overflow: hidden;
	height: 95px;
  top: 5px;
}
#divlines 
{
	position: absolute;
  font-weight: bold;
}
#text1 {
  margin-left: 16px;
	overflow-x: scroll;
  width: 300px;
	min-height: 99px;
	font-size: 14px;
  padding: 4px;
  &.error {
    border: 1px solid red;
    &:focus {
      outline: none;
      border: 1px solid red;
    } 
  }
}
.highlight {
  color: red;
}
.errortext {
  display: block;
  margin-left: 16px;
  font-size: 12px;
  color: DarkBlue;
  font-family: "Helvetica Neue", Arial;
}
.hint + .errortext {
  display: none;
}

#reset {
  margin-top: 30px;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 14px;
  background-color: #046a9d;
  color: white;
  border-color: #004667;
}
              
            
!

JS

              
                var lines = document.getElementById("divlines");
var txtArea = document.getElementById("text1");
window.onload = function() {
  refreshlines();
  checklines();
  txtArea.onscroll = function() {
    lines.style.top = -txtArea.scrollTop + "px";
    return true;
  };
  txtArea.onkeyup = function() {
    refreshlines();
    checklines();
    return true;
  };
};

function refreshlines() {
  var nLines = txtArea.value.split("\n").length;
  lines.innerHTML = "";
  for (i = 1; i <= nLines; i++) {
    lines.innerHTML = lines.innerHTML + `<span>➜</span>` + "<br />";
  }
  lines.style.top = -txtArea.scrollTop + "px";
}

function checklines() {
  var nLines = txtArea.value.split("\n").length;
  var tLines = txtArea.value.split("\n");
  for (var i = 0; i < nLines; i++) {
    if (tLines[i].includes("link")) {
      txtArea.classList.add("hint");
    } else {
      var lineNum = (2*i);
      var errorT = lines.children[lineNum];
      errorT.style.color = "black";
      errorT.style.fontWeight = "100";
      errorT.style.opacity = "0";
      txtArea.classList.remove("hint");
    }
  }
}

function resetText() {
  txtArea.classList.remove("hint");
}

              
            
!
999px

Console