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.
<main id = "main">
<header id = "title">
<h1>Mahendra Singh Dhoni</h1>
</header>
<p class = "sub-text">The cricketer who made the dreams of a billion people a reality</p>
<figure id = "img-div">
<img src = "https://s.ndtvimg.com/images/content/2014/dec/806/ms-dhoni-with-world-cup.jpg" alt = "Picture of Dhoni" id = "image">
<figcaption id = "img-caption">Dhoni with 2011 WC Trophy</figcaption>
</figure>
<article id = "tribute-info">
<h2>Timeline of Dhoni's Career</h2>
<ul>
<li><span class = "date">December 2004: </span>Dhoni makes his international debut against Bangladesh in an ODI at Chittagong.</li>
<li><span class = "date">October 2005: </span>Scored 183 against Sri Lanka, highest individual score for a wicket-keeper.</li>
<li><span class = "date">December 2005: </span> Dhoni makes his Test debut against Sri Lanka in Chennai.</li>
<li><span class = "date">September 2007: </span> Dhoni takes over the reins of ODI captaincy from Rahul Dravid.</li>
<li><span class = "date">September 2007: </span>Beats Pakistan in the final of the inaugral ICC World T20.</li>
<li><span class = "date">August 2008:</span> Dhoni wins the Rajiv Gandhi Khel Ratna award.</li>
<li><span class = "date">November 2008:</span>Dhoni makes his debut as full-time Test captain of India during the fourth and final Test against Australia at Nagpur.</li>
<li><span class = "date"> December 2008:</span>Dhoni wins the ICC ODI Player of the Year honour.</li>
<li><span class = "date">March 2009: </span> Dhoni leads India to its first bilateral ODI series victory in New Zealand.</li>
<li><span class = "date">April 2009: </span> Dhoni honoured with the Padma Shri, India's fourth highest civilian honour.</li>
<li><span class = "date">December 2009: </span> Under Dhoni's captaincy, India tops the ICC Test cricket rankings for the first time.</li>
<li><span class = "date">December 2009: </span> Dhoni retains his ICC ODI Player of the year award, becomes the first player to win it twice.</li>
<li><span class = "date">May 2010: </span> Dhoni leads Chennai Super Kings to their maiden Indian Premier League title, beating Mumbai Indian by 22 runs in the final.</li>
<li><span class = "date">April 2011: </span> Dhoni scores 91<sup>*</sup> off 79 balls against Sri Lanka in the World Cup final to help India lift the trophy after 28 years.</li>
<li><span class = "date">May 2011: </span> Chennai Super Kings retain the IPL, beat Royal Challengers Banglore by 58 runs in the final.</li>
<li><span class = "date">November 2011: </span> The Indian Territorial Army confers the honorary rank of Lieutenant Colonel on Dhoni.</li>
<li><span class = "date">March 2013: </span> Dhoni becomes the most successful Indian Test captain, eclipses Sourav Ganguly's record of 21 victories from 49 Tests.</li>
<li><span class = "date">June 2013: </span> India win the ICC Champions Trophy by defeating England by five runs in the final. He became the first captain to win all 3 ICC trophies.</li>
<li><span class = "date">February 2013: </span> Dhoni powers his way to his first double hundred in Tests, scoring 224 off 365 balls against Australia.</li>
<li><span class = "date">March 2013: </span>India beats Australia 4-0 at home for the first time in a Test series.</li>
<li><span class = "date">March 2015: </span>Leads India to the World Cup semi-final, but fall short against Australia.</li>
<li><span class = "date">January 2017: </span>Steps down as Indian captian and hands the reins to Virat Kohli.</li>
<li><span class = "date">April 2018: </span> Dhoni receives the Padma Bhushan, India's third-highest civillian honour.</li>
<li><span class = "date">May 2018: </span> Chennai Super Kings win their third IPL title by defeating Sunrisers Hyderabad by eight wickets.</li>
<li><span class = "date">August 2020: </span> Announces retirement from all forms of cricket.</li>
</ul>
<blockquote>"He knows exactly what he wants to do in the middle. He is always calm and composed. He allows himself to make those tough decisions on the field. For me, he will always be my captain." – Virat Kohli</blockquote>
</article>
<footer>
To learn more about this <a href = "https://en.wikipedia.org/wiki/MS_Dhoni" id = "tribute-link" target = "_blank">cricketing legend.</a>
</footer>
</main>
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html{
font-size: 10px;
}
body{
min-height: 100vh;
min-width: 100vw;
background: #536976; /* fallback for old browsers */
background: linear-gradient(to right, #292E49, #536976);
text-align: center;
font-family: 'Roboto', sans-serif;
}
#main{
margin:8%;
background-color: #eee;
}
#title{
font-size: 3rem;
padding: 4rem;
}
.sub-text{
font-size: 2rem;
}
#img-div{
margin: 15px 0;
padding: 0;
}
#image{
max-width: 100%;
display: block;
margin: 0 auto;
height: auto;
}
#img-caption{
font-size: 1.2rem;
margin: 10px 0;
}
h2{
text-align: center;
font-size: 3rem;
margin: 2rem 0;
}
.date{
font-weight: bold;
}
li{
margin: 16px 0;
}
ul{
max-width: 60%;
padding: 0 1rem;
margin: 0 auto 30px auto;
font-size: 1.7rem;
text-align: left;
line-height: 1.5;
}
blockquote{
max-width: 70%;
color: gray;
font-size: 1.6rem;
padding: 0 1rem;
margin: 0 auto;
text-align: left;
}
footer{
font-size: 2.5rem;
padding: 3rem 2rem;
}
#tribute-link{
color: #536976;
text-decoration: none;
}
#tribute-link:hover{
text-decoration: underline;
}
@media (max-width: 600px)
{
#main{
margin: 5%;
}
#title{
font-size: 1.8rem;
padding: 1.5rem;
}
.sub-text{
font-size: 1.3rem;
}
#img-caption{
font-size: 1.2rem;
padding: 0.7rem;
}
h2{
font-size: 1.8rem;
}
ul {
max-width: 75%;
font-size: 1.4rem;
}
blockquote{
max-width: 90%;
font-size: 1.4rem;
font-weight: bold;
line-height: 1.4;
padding: 0 1rem;
margin: 0 auto;
text-align: left;
}
footer{
font-size: 2rem;
padding: 3rem 2rem;
}
}
/*User Story #1: My tribute page should have an element with a corresponding id="main", which contains all other elements.
User Story #2: I should see an element with a corresponding id="title", which contains a string (i.e. text) that describes the subject of the tribute page (e.g. "Dr. Norman Borlaug").
User Story #3: I should see a div element with a corresponding id="img-div".
User Story #4: Within the img-div element, I should see an img element with a corresponding id="image".
User Story #5: Within the img-div element, I should see an element with a corresponding id="img-caption" that contains textual content describing the image shown in img-div.
User Story #6: I should see an element with a corresponding id="tribute-info", which contains textual content describing the subject of the tribute page.
User Story #7: I should see an a element with a corresponding id="tribute-link", which links to an outside site that contains additional information about the subject of the tribute page. HINT: You must give your element an attribute of target and set it to _blank in order for your link to open in a new tab (i.e. target="_blank").
User Story #8: The img element should responsively resize, relative to the width of its parent element, without exceeding its original size.
User Story #9: The img element should be centered within its parent element.*/
Also see: Tab Triggers