Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

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.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<html lang="en">
	

	<head>

		<meta charset="utf-8">

		<!--
			The <meta> element below is important to help change the size of our browser window to reflect the size of the device. It works as follows:

				name="viewport" - this clarifies that we are declaring something about the viewport (aka browser window)
				'width=device-width' - this specifies that the width of the viewport should be equal to the width of our device (important for mobile devices)
				'initial-scale=1' - this ensures that our website renders not zoomed-in or zoomed-out, as we have designed it to be responsive.

			If you would like more information on why we set this, I recommend reading this article - https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
		-->
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<title>My Most Hideous Page Ever</title>


		<!-- 
			The <link> element is used to connect other resources to our document. Since it links resources it is self closing as well as it uses the href attribute to refer to the file we want to connect to. In this case, we establish a link with a 'relationship' (rel) as a stylesheet.

			normalize.css is a pre-built stylesheet that attempts to 'normalize' differences in how different browsers render an HTML page by default. More info (and the most recent version) is available at https://necolas.github.io/normalize.css/
		-->
		<link rel="stylesheet" href="css/normalize.css"> 

		<!-- 
			Keep in mind that the order of our stylesheets will dictate the order in which styles are applied. If we want our styles to override the 'normalizing' that normalize.css does, we should load main.css after our normalize.css file.
		-->
		<link rel="stylesheet" href="css/main.css">

	</head>
	<body>

		<header>

			<h1>My Less Hideous Page Ever</h1>

			<nav>
				<!-- 
					Here we are adding the 'class' attribute to link to a more specific styling in our 'main.css' stylesheet. Saying class="nav-main-item" connects this styling to our .nav-main-item declaration in our CSS file.
				-->
				<a href="#introduction" class="nav-main-item">An introduction</a>
				<a href="#kittens" class="nav-main-item">To the kittens</a>
			</nav>

		</header>


		<section id="introduction">
				
			<h2>An introduction</h2>

			<p>
				<strong>Very exciting things are happening</strong>. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
			</p>

		</section>


		<section id="kittens">

			<h2>Kittens are da cutest!</h2>

			<figure>

				<img src="https://andrewh.ca/teaches/information_design/tutorials/02/explanation/img/kitten.jpg" alt="A blue eyed kitten standing over a bowl of milk with a milk beard" width="1200" height="627">

				<figcaption>
					It's a bundle of cute, cuddly, danger! 
					<a href="http://placekitten.com">Photo from placekitten</a>
				</figcaption>

			</figure>


			<ol>
				<li>The <em>first</em> reason why kittens are dangerous.</li>
				<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
				<li>Aliquam tincidunt mauris eu risus.</li>
			</ol>

		</section>


	</body>
</html>

              
            
!

CSS

              
                /*
	This is a comment in CSS. It will be viewable in the source code.
*/


/*
	Welcome to CSS styling! This is how we style our HTML pages. It is important to note how we select and change the styling for an element:

	selector {
		property: value;
		property2: value2;
	}

	selector - The item we are selecting to be restyled. This can be an element name such as h1 or img, or the name of an id or class (#robots, .item-class)
	property - A CSS property that we want to restyle the element with, such as font-size or color.
	value - The value we want to set the property to, such as 16px or blue.

	Make sure to separate different property/value statements with a colon between property: value, and a semicolon at the end of the property: value; statement. 
*/



/*
	Below we have selected the body element - aka <body> - and are setting some styling for it. Generally it is a good idea to only select entire sets of elements to set default stylings. Aim to use classes when styling elements more specifically.
*/
body {
	/*
		Font family works by stating a series of fonts in order from most to least specific. The reason is to ensure that if the first font is not available, that we have fall-backs that the browser can load up if needed.
	*/
	font-family: Helvetica, Verdana, sans-serif;

	/*
		Margin sets the spacing outside of the borders of an element's box. Because we are only setting one value below, it makes it the margin value for all sides of our box, which in this case is all sides of our body element.
	*/
	margin: 1rem;

	/*
		Setting a default font size for all elements who are children of the body tag. How 'rems' work are explained in the next comment.
	*/
	font-size: 1rem;
}



/*
	With the selection of the different heading elements below, we are using 'rem' units to establish a default hierarchy for their font sizes. Rem units refer to 'root-em' which are a multiple of the base font-size set by the browser. As a result, rem units are particularly useful for establishing hierarchies in type.
*/
h1 {
	font-size: 3rem;
	/*
		We can be more specific than just 'margin' with our property and specify 'margin-bottom' instead. In this case, because we are setting a value of 0, there is no need to add a unit to the value.
	*/

	margin-bottom: 0;
}

h2 {
	font-size: 2.25rem;
	margin-bottom: 0;
}



/*
	Below we are setting defaults for a series of selectors. The comma allows us to select a combination of elements.
*/
p, ol, ul {

	/*
		max-width is a property which easily allows us to ensure something does not extend past a certain point in width. In this case, we can use it to make line-lengths more manageable in our text.
	*/
	max-width: 40rem;
}



img {
	/* 
		We are saying we want the img to adjust its height accordingly when the width changes.
	*/
	height: auto; 

	/* 
		Then we tell it we don't want it to exceed 100% of the parent element. In this case it resizes with the 'body' tag (the browser window).
	*/
	max-width: 100%;

	/* 
		The three statements below allow us to set a border around our images, in order they set the width, the style (dashed, solid, etc), and then the color of the border.
	*/
	border-width: 1px;
	border-style: solid;
	border-color: black; 
}


/*
	Because the figure element has a margin set on it by default, if we do not want it to have a margin we have to set the margin to zero.
*/
figure {
	margin: 0;
}

figcaption {
	font-style: italic;
}



a {
	/*
		Setting colours for elements can be done in a variety of ways. You can use just the colour name 'blue', you can use a HEX value '#00AAFF', you can specify an rgb value 'rgb(0,200,255)', and you can specify an rgb value with alpha (or opacity) using 'rgba(0,200,255,0.8)' (80%).
	*/
	color: rgb(200,0,0);

	/*
		The transition property makes it very easy to create smooth transitions for different CSS properties. In this case, with the two statements below we are specifying that we want to transition the 'color' property over 0.5 seconds. Note that you have to have another state for the element - example below in a:hover - for it to actually make use of the transition.
	*/
	transition-property: color;
	transition-duration: 0.5s;
}



/* 
	The :hover and :focus are pseudo-states for elements. In this case, we are saying when the anchor tag is the 'hover' (being hovered over) and 'focus' (selected by keyboard, i.e. tab) states it should apply the styling specified.
*/
a:hover, a:focus {
	color: rgb(50,0,0); 
	/*
		The text-decoration property allows us to add or remove underlining. In this case we are removing it.
	*/
	text-decoration: none;
}



/*
	Here we are selecting the elements with the .button class that are inside of the nav tag
*/
.nav-main-item {
	display: inline-block;
	color: white;
	background-color: rgb(250,100,75);
	font-size: 1.5rem;
	
	/*
		By setting two values for padding below, we are now specifying different values for the top/bottom and the left/right in that order. This compound declaration can also be used to set different padding values for each of the sides of a box in top, right, bottom, left order. Example:

		padding: top right bottom left; would be 
		padding: 10rem 5rem 2rem 12rem;
	*/
	padding: 0.5rem 0.75rem;

	/*
		Because our anchor tags have an underline by default, we end up having to remove them for our buttons (by default).
	*/
	text-decoration: none;

	/*
		Unlike our prior transition statement, here we are also adding a type of easing to the transition.
	*/
	transition-property: background-color;
	transition-duration: 0.5s;
	transition-timing-function: ease-out;
}


.nav-main-item:active, .nav-main-item:hover, .nav-main-item:focus {
	color: white;
	background-color: rgb(50,50,50);
}


              
            
!

JS

              
                
              
            
!
999px

Console