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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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