Click here to Skip to main content
15,890,043 members
Articles / Web Development / HTML
Tip/Trick

Create a Midnight Rainbow with a little HTML and CSS

Rate me:
Please Sign up or sign in to vote.
3.25/5 (7 votes)
22 Apr 2015CPOL 20K   5   6
Simple example for kids and novices of using HTML and CSS to create a colorful "midnight rainbow" effect

Startling Revelation

I went to school with Roy G. Biv; I'm proud to say that he was a friend of mine. Roy G. and his buddy Hue saturated me with colorful knowledge, and they were on the level.

So, I'm "paying it forward," kids, and showing you how, with a modicum of HTML and CSS, you can create a rainbow in the midnight sky (or so it seems, if you use your imagination).

Here is the HTML:

HTML
<h1>
<span class="r">R</span>
<span class="o">a</span>
<span class="y">i</span>
<span class="g">n</span>
<span class="b">b</span>
<span class="i">o</span>
<span class="v">w</span>
</h1>
<p>Look, Ma (and/or Pa)! I created a "Midnight Rainbow" with a little HTML and CSS!!!</p>

...and here is the CSS:

CSS
h1 {
    font-size: 500%;
    font-family: "Palatino Linotype", "Century Gothic", "Baskerville", "Consolas", "Candara", "Lucida Sans", serif;
}
body {
    background-color: black;
    font-family: "Lucida Sans", serif;
    color: white;
}
.r {
   color: hsl(0, 100%, 50%);
}
.o {
   color: hsl(30, 100%, 50%);
}
.y {
   color: hsl(60, 100%, 50%);
}
.g {
   color: hsl(120, 100%, 50%);
}
.b {
   color: hsl(240, 100%, 65%);
}
.i {
   color: hsl(280, 100%, 60%);
}
.v {
   color: hsl(300, 100%, 50%);
}

You can see an example of this here.

Or, if you sprained your clicking finger, it should look something like this:

Regenbogen

TiNSTAaFT

(That stands for, "There is No Such Thing As a Free Tip"). If you like this, make a paper-machete statue of good ol' Roy G. Biv and paint it the colors of the rainbow (red, orange, yellow, green, blue, indigo (AKA blue-violet), and violet)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Across Time & Space
United States United States
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven

Comments and Discussions

 
QuestionMake it a tip and add an image... Pin
.dan.g.23-Apr-15 14:34
professional.dan.g.23-Apr-15 14:34 
AnswerRe: Make it a tip and add an image... Pin
B. Clay Shannon23-Apr-15 14:56
professionalB. Clay Shannon23-Apr-15 14:56 
GeneralRe: Make it a tip and add an image... Pin
.dan.g.23-Apr-15 15:51
professional.dan.g.23-Apr-15 15:51 
QuestionUm no... Pin
Jeremy Falcon22-Apr-15 12:14
professionalJeremy Falcon22-Apr-15 12:14 
AnswerRe: Um no... Pin
B. Clay Shannon22-Apr-15 12:19
professionalB. Clay Shannon22-Apr-15 12:19 
AnswerRe: Um no... Pin
B. Clay Shannon22-Apr-15 12:20
professionalB. Clay Shannon22-Apr-15 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.