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

              
                .container
  .row
    .col.third
      | 1. has <code>\n</code> &amp; comment.
      pre.code
        | &lt;div&gt;
        |   &lt;!-- comment--&gt;
        | &lt;/div&gt;
    .col.third
      | 2. has white space.
      pre.code
        | &lt;div&gt; &lt;/div&gt;
    .col.third
      | 3. has commint
      pre.code
        | &lt;div&gt;&lt;!-- comment--&gt;&lt;/div&gt;
  .row
    .cell
      h3
        code :blank
      a(href="https://css-tricks.com/almanac/selectors/b/blank/#browser-support", target="_blank", rel="noopener") support: 
        code :blank
      | *moz only
    .cell
      h3
        code :empty
      a(href="https://caniuse.com/#feat=css-sel3", target="_blank", rel="noopener") support: 
        code :empty
  .row
    .cell
      .row.blank
        .col
          | 1.
          //- comment & line feed code
          .square
            // comment
        .col
          | 2.
          //- has space
          .square= " "
        .col
          | 3.
          //- inline comment
          .square!= "<!--comment-->"
    .cell
      .row.empty
        .col
          | 1.
          //- comment & line feed code
          .square
            // comment
        .col
          | 2.
          //- has space
          .square= " "
        .col
          | 3.
          //- inline comment
          .square!= "<!--comment-->"
          
#app.container
              
            
!

CSS

              
                *
  box-sizing: border-box
.row
  display: flex
  flex-direction: row
  flex-wrap: wrap
  justify-content: center
  margin-bottom: 1em
.cell
  padding: 0 30px
  width: 50%
.third
  width: 33.333%

.container
  margin: 0 auto 3em
  max-width: 760px

.deleteBtn
  margin-left: .5em
  cursor: pointer
.addBtn
  cursor: pointer

.list
  padding-left: 1em
  
.blankList
  &:blank
    height: 1em
    background-color: #ec4727
.blankList
  &:-moz-only-whitespace
    height: 1em
    background-color: #ec4727
    
.emptyList
  &:empty
    height: 1em
    background-color: #fbc136
    
.square
  margin: 0 .5em
  width: 60px
  height: 60px
  background-color: #4fa7f0
  
.blank
  .square
    &:blank
      background-color: #ec4727
.blank
  .square
    &:-moz-only-whitespace
      background-color: #ec4727
.empty
  .square
    &:empty
      background-color: #fbc136

pre.code
  margin: 0 15px
  background-color: #e7e9ec
              
            
!

JS

              
                // state
const defaultItems = [
  {label: "One"},
  {label: "Two"},
  {label: "Three"},
];

function TodoItem(props) {
  const item = props.item;
  return(
    <li>
      <label>{item.label}</label>
      <button className="deleteBtn" onClick={props.onDelete}><i className="fui-cross"></i></button>
    </li>
  );
}

class TodoList extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      items: props.list
    }
  }
  
  _onDelete(i) {
    const data = this.state.items.slice();
    data.splice(i, 1)
    
    this.setState({
      items: data
    });
  }
  
  _onAdd(e) {
    e.preventDefault();
    const data = this.state.items.slice();
    const inp = e.target.firstChild;
    const val = inp.value
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;');
    data.push({label: val});
    this.setState({
      items: data,
    });
    e.target.reset();
  }
  
  render() {
    const list = this.state.items;
    return (
      <>
        <ul className={this.props.className}>
          {list.map( (item, i) => <TodoItem key={i} item={item} onDelete={() => this._onDelete(i)} /> )}
        </ul>
        <Actions onSubmit={(e) => this._onAdd(e)}/>
      </>
    );
  }
}

function App() {
  return (
    <div className="row">
      <div className="cell">
        <h5><code>:blank</code> TODO LIST</h5>
        <TodoList className="list blankList" list={defaultItems} />
      </div>
      <div className="cell">
        <h5><code>:empty</code> TODO LIST</h5>
        <TodoList className="list emptyList" list={defaultItems} />
      </div>
    </div>
  );
}

function Actions(props) {
  return (
    <form onSubmit={props.onSubmit}>
      <input className="form-control" type="text" placeHolder="ADD LIST" />
      <button className="btn btn btn-primary addBtn" type="submit">ADD</button>
    </form>
  );
}

ReactDOM.render(<App />, document.querySelector('#app'));
 
              
            
!
999px

Console