<!-- :read-write -->
<section class="example-cntr read-write">
    <h1>CSS <code>:read-write</code> pseudo-class</h1>
    <p>The <code>:read-write</code> pseudo-class targets elements that <span class="underline">can</span> be edited by the user. It can work on elements that have the <code>contenteditable</code> HTML attribute as well.</p>
    <p>This pseudo-class can be combined with the <code>:focus</code> pseudo-class to enhance the UX under particular situations.</p>
    <p>In the following example, this DIV <span class="underline">can</span> be edited in the browser by clicking on it. Since this piece of content is editable by the user the UX can be enhanced by applying a particular styling that will differentiate it
        from the rest of the content and provide a visual cue to the user that the content can be edited:</p>
    <div class="editable" contenteditable>
        <h1>Click on this text to edit it</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad quod ducimus corporis iusto, ratione pariatur!</p>
    </div>
</section>
//:read-write
.read-write {
    .editable {
        padding: 40px;
        font: 22px Garamond;
        color: lighten($g,30);
        outline: 1px transparent dashed;
        transition: .6s;
        &:read-write:focus {
            outline-color: white;
            font-style: italic;
        }
    }
    h1 { text-align: left; }
}


//Styling stuff not needed for demo
body {
    text-align: left;
    line-height: 1.5;
}
h1 {
    font-size: 22px;
    text-transform: none;
    border-bottom: #636363 1px dotted;
    code {
        display: inline-block;
        margin-bottom: 10px;
        color: $y;
        background: none;
        box-shadow: none;
    }
}
code { font-size: 1em; }
.example-cntr {
    max-width: 800px;
    margin: 0 auto 50px;
    padding: 30px;
    box-shadow: 0 1px 2px rgba(black,.3);
    background: rgba(black,.15);
    & > code {
        display: block;
        margin-bottom: 10px;
        font-size: 22px;
        color: $y;
        background: none;
        box-shadow: none;
    }
    & > h1 {
         text-align: center;
    }
}
.flex-ctnr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}
small {
    display: block;
    margin: 20px 0 10px;
    padding-top: 10px;    
    text-align: center;
}
span {
    &.red,
    &.green,
    &.yellow {
        display: inline-block;
        font-weight: bold;
        font-size: 18px;
        text-shadow: 0 1px 0 #000;
    }
}
.underline { text-decoration: underline; }
.red { color: $r; }
.green { color: $g; }
.yellow { color: $y; }
View Compiled

External CSS

  1. https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/codepen-base_3.scss

External JavaScript

This Pen doesn't use any external JavaScript resources.