cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>Using CSS Variables</h1>

<h2>Example</h2>
<div class="example">
    <p>
        Made a meal and threw it up on Sunday
        <br>I've gotta lot of things to learn
        <br>Said I would and I'll be leaving one day
        <br>Before my heart starts to burn
    </p>

    <p>So what's the matter with you?
        <br>Sing me something new
        <br>Don't you know the cold and wind and rain don't know
        <br>They only seem to come and go away
    </p>
    
    <cite>~ <a href="https://www.youtube.com/watch?v=maTP315XZCQ" title="Stand by Me by Oasis on YouTube">Stand by Me by Oasis</a></cite>
</div>

<div class="content">
    <h2>Explanation</h2>
    <p>In case the browser does not support CSS Variables, it will read <code>color: red;</code> as the rule for the selector <code>cite a</code>.</p>
    <p>In any other case, it will read the second rule which contains the variable name <code>color: var(--cite-link--color);</code>. It's important to note that it should be below the non-variable rule to override it.</p>
</div>
            
          
!
            
              /* Variables */
:root
{
    /* Absolute */
    --panda-blue--color: #005fe6;

    /* Generic */
    --color--accent-pri: var(--panda-blue--color);

    /* Specific */
    --cite-link--color: var(--color--accent-pri);
}

/* Cite Link */
cite a
{
    color: red;
    color: var(--cite-link--color);
    
    text-decoration: none;
}

cite a:hover
{
    text-decoration: underline;
}

html
{
    /* Text Formatting */
    font-size: 1.125rem;
    line-height: 1.6;
    font-family: sans-serif;
}

.example
{
    background-color: #f2f2f2;
}
            
          
!
999px
Loading ..................

Console