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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

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.


  Click and drag to highlight elements below. The text will highlight and be seen in the form field and as a URL parameter.

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qua tu etiam inprudens utebare non numquam. Hoc est non dividere, sed frangere. Tecum optime, deinde etiam cum mediocri amico. Polemoni et iam ante Aristoteli ea prima visa sunt, quae paulo ante dixi. Non est igitur summum malum dolor. Quae cum praeponunt, ut sit aliqua rerum selectio, naturam videntur sequi; Duo Reges: constructio interrete. Cum autem in quo sapienter dicimus, id a primo rectissime dicitur.

Eadem fortitudinis ratio reperietur. Sed ea mala virtuti magnitudine obruebantur.

  <input type="text" name="highlight" id="hi"><br> 

<a id="my-link" href=""></a>


              body {
  width: 700px;
  padding: 2em;
  margin: 0 auto;

#hi {
  width: 50%;
  height: 3em;

.active {
  margin: 2em 0;
  border: 1px solid;
  padding: .5em;

#my-link:hover {
  background-color: #efefef;


              // modified a bit from
//other thing used was

var url = window.location.href;

//get highlighted text
function getSelectedText() {
        var text = "";
        if (typeof window.getSelection != "undefined") {
            text = window.getSelection().toString();
        } else if (typeof document.selection != "undefined" && document.selection.type == "Text") {
            text = document.selection.createRange().text;
        return text;

//set the form field and build the a href link
    function setField() {
        var selectedText = getSelectedText();
        var field = document.getElementById('hi');
        var link = document.getElementById('my-link');
        if (selectedText) {
            field.value = getSelectedText();
            link.href = ''+encodeURIComponent(selectedText)+'&url='+url; //builds URL
            link.innerHTML = "Submit";//sets text for the button
            link.classList.add("active"); //adds a class to the link to make it prettier
    document.onmouseup = setField;
    document.onkeyup = setField;

//adds/removes highlighting background color
function highlightIt(){
  var b = document.getElementsByTagName('span');
while(b.length) {
    var parent = b[ 0 ].parentNode;
    while( b[ 0 ].firstChild ) {
        parent.insertBefore(  b[ 0 ].firstChild, b[ 0 ] );
     parent.removeChild( b[ 0 ] );

  var range = window.getSelection().getRangeAt(0);
  var newNode = document.createElement("span");
  range.surroundContents(newNode); = "yellow";