HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Inspirational Quote of the Day</title>
<link rel="stylesheet" href="quote.css">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
<script src="jquery-1.11.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<h2>Get Your Daily Quote</h2>
<div id="quoteContainer">
<p></p>
<p id="quoteGenius"></p>
</div><!--end quoteContainer-->
<div id="buttonContainer">
<a href="#" id="quoteButton">Quote Me</a>
</div><!--end buttonContainer-->
</div><!--end container-->
</body>
</html>
body{
font-family: 'Roboto', sans-serif;
color: #000;
}
#container{
width:800px;
margin:50px auto;
padding: 20px;
width:50%;
}
#container h2{
text-align:center;
color:#045;
}
#quoteContainer{
width:75%;
background: #fff;
padding:10px;
margin:30px auto;
text-align: center;
height:70px;
}
#buttonContainer{
width: 100%;
text-align: center;
}
#quoteButton{
width:200px;
margin-top: 10px;
border:2px solid #46b8da;
color:#045;
font-family: inherit;
font-weight: bold;
padding:5px;
text-decoration: none;
text-align: center;
}
#quoteButton:hover{
cursor:pointer;
background:#09c;
color: #fff;
}
#quoteButton:active{
cursor: pointer;
}
#quoteButton{
display: inline-block;
}
#quoteGenius{
font-style: italic;
font-weight: 600;
text-align: center;
}
/*MEDIA QUERIES*/
@media screen and(max-width:760px){
#quoteButton,#addNew{
display: block;
}
}
$(document).ready(function(){
var quoteSource=[
{
quote: "Start by doing what's necessary; then do what's possible; and suddenly you are doing the impossible.",
name:"Francis of Assisi"
},
{
quote:"Believe you can and you're halfway there.",
name:"Theodore Roosevelt"
},
{
quote:"It does not matter how slowly you go as long as you do not stop.",
name:"Confucius"
},
{
quote:"Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.",
name:"Thomas A. Edison"
},
{
quote:"The will to win, the desire to succeed, the urge to reach your full potential... these are the keys that will unlock the door to personal excellence.",
name:"Confucius"
},
{
quote:"Don't watch the clock; do what it does. Keep going.",
name:"Sam Levenson"
},
{
quote:"A creative man is motivated by the desire to achieve, not by the desire to beat others.",
name:"Ayn Rand"
},
{
quote:"A creative man is motivated by the desire to achieve, not by the desire to beat others.",
name:"Ayn Rand"
},
{
quote:"Expect problems and eat them for breakfast.",
name:"Alfred A. Montapert"
},
{
quote:"Start where you are. Use what you have. Do what you can.",
name:"Arthur Ashe"
},
{
quote:"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.",
name:"Samuel Beckett"
},
{
quote:"Be yourself; everyone else is already taken.",
name:"Oscar Wilde"
},
{
quote:"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.",
name:"Albert Einstein"
},
{
quote:"Always remember that you are absolutely unique. Just like everyone else.",
name:"Margaret Mead"
},
{
quote:"Do not take life too seriously. You will never get out of it alive.",
name:"Elbert Hubbard"
},
{
quote:"People who think they know everything are a great annoyance to those of us who do.",
name:"Isaac Asimov"
},
{
quote:"Procrastination is the art of keeping up with yesterday.",
name:"Don Marquis"
},
{
quote:"Get your facts first, then you can distort them as you please.",
name:"Mark Twain"
},
{
quote:"A day without sunshine is like, you know, night.",
name:"Steve Martin"
},
{
quote:"My grandmother started walking five miles a day when she was sixty. She's ninety-seven now, and we don't know where the hell she is.",
name:"Ellen DeGeneres"
},
{
quote:"Don't sweat the petty things and don't pet the sweaty things.",
name:"George Carlin"
},
{
quote:"Always do whatever's next.",
name:"George Carlin"
},
{
quote:"Atheism is a non-prophet organization.",
name:"George Carlin"
},
{
quote:"Hapiness is not something ready made. It comes from your own actions.",
name:"Dalai Lama"
}
];
$('#quoteButton').click(function(evt){
//define the containers of the info we target
var quote = $('#quoteContainer p').text();
var quoteGenius = $('#quoteGenius').text();
//prevent browser's default action
evt.preventDefault();
//getting a new random number to attach to a quote and setting a limit
var sourceLength = quoteSource.length;
var randomNumber= Math.floor(Math.random()*sourceLength);
//set a new quote
for(i=0;i<=sourceLength;i+=1){
var newQuoteText = quoteSource[randomNumber].quote;
var newQuoteGenius = quoteSource[randomNumber].name;
//console.log(newQuoteText,newQuoteGenius);
var timeAnimation = 500;
var quoteContainer = $('#quoteContainer');
//fade out animation with callback
quoteContainer.fadeOut(timeAnimation, function(){
quoteContainer.html('');
quoteContainer.append('<p>'+newQuoteText+'</p>'+'<p id="quoteGenius">'+'- '+newQuoteGenius+'</p>');
//fadein animation.
quoteContainer.fadeIn(timeAnimation);
});
break;
};//end for loop
});//end quoteButton function
});//end document ready
Also see: Tab Triggers