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>

		<link rel="stylesheet" href="css/normalize.css">	
		<!-- 
			Here we are linking up a separate stylesheet to manage our grid structures.
		-->
		<link rel="stylesheet" href="css/grid.css">
		<link rel="stylesheet" href="css/main.css"> 
		<link rel="stylesheet" href="css/fonts.css"> 


	</head>

	<body>

		<h1>My Less Hideous Page</h1>

		<p>
			A robot is a <em>dangerous</em>, often humanoid, autonomous being that will take over soon. We must be vigilant. We must be wary. We must prepare to stop the robots from taking over. Transformers are here and are real. Robots such as Honda's <abbr title="Advanced Step in Innovative Mobility">ASIMO</abbr> is proof of that. They walk, and soon enough they will also be able to talk and drive us around. That is dangerous.
		</p>


		<!--
					Below we have added a <div> element to act as a non-semantic HTML element to apply our grid styling to. Note that we have assigned three separate CSS classes to our element by separating them with spaces. In this case our <div> below has the CSS classes of: .grid and .four-column and .add-gutters
		-->
		<nav class="nav-main grid four-column add-gutters">

			<!-- 
				In the case of our grid, the child elements of the grid - in this case the <a> below that are the children of the <nav class="grid ..."> - are what form each 'cell' of the grid. If you need to place more than just a single element in a cell, then they need to be wrapped inside of another element. A good example of this is available below at line 75.
			-->
			<a href="#robot" class="nav-main-item">See a Robot</a>
			<a href="#comments" class="nav-main-item bg1">Comment on Robots</a>
			<a href="https://en.wikipedia.org/wiki/Robot" class="nav-main-item bg2">Robots (Wikipedia)</a>
			<a href="https://www.shutterstock.com/search/robots?search_source=base_keyword" class="nav-main-item bg3">Robot Photos</a>
		
		</nav>

		<section id="robot">
		
			<h2>See a Robot</h2>
			
			<!--
				Below we have added a <div> element to act as a non-semantic HTML element to apply our grid styling to. Note that we have assigned three separate CSS classes to our element by separating them with spaces. In this case our <div> below has the CSS classes of: .grid and .two-column and .add-gutters
			-->
			<div class="grid two-column add-gutters">
		
				
				
				<!-- 
					In the case of our grid, the child elements of the grid - in this case the <figure> and <div> elements below that are the children of the <div class="grid ..."> - are what form each 'cell' of the grid. In the example below all the content that is inside of each element will fill one cell of our grid.
				-->
				<figure>

					<img src="https://andrewh.ca/teaches/web_design_and_development/tutorials/03/explanation/img/robot.jpg" alt="A toy robot with a menacing expression" height="1600" width="1063">
					<figcaption>Beware of robots like this.</figcaption>

				</figure> <!-- This is the end of the first column -->
					
				<!-- 
					The <div class="column"> wraps all the content we want to appear in a column of our grid. The .column class has no CSS applied to it.
				-->
				<div class="column">
					<h3>Links about robots:</h3>
					<ol>

						<li>
							<a href="https://en.wikipedia.org/wiki/Robot" target="_blank">Wikipedia on Robots</a>
						</li>
						<li>
							<a href="https://www.shutterstock.com/search/robots?search_source=base_keyword" target="_blank">Photos of robots</a>
						</li>
					</ol>
				</div> <!-- This is the end of the second column -->


			</div> <!-- This is the end of our grid -->



			<h3>The code of how robots deal with humans:</h3>

			<code>
				# Human protocol<br>
				robot.see("human", function(seen) {<br>
				seen.destroy();<br>
				});<br>
			</code>

			<h3>What the robot does as a result:</h3>

			<samp>EXTERMINATE! EXTERMINATE! EXTERMINATE!</samp>

		</section>


		<section id="comments">

			<h2>Comment on Robots</h2>
			<p><strong>Commenting is currently closed.</strong></p>

		</section>


	</body>
</html>
              
            
!

CSS

              
                /* THIS IS IN GRIDS.CSS IN THE TUTORIAL FILES */
/*
	With the asterisk (*) selector, we are specifying that all objects use the border-box model (not the content-box model)
*/
* {
	box-sizing: border-box;
}





/*
	A reminder that here we are defining our own 'class' which we can then apply repeatedly to our HTML elements. In this case, in our HTML if we apply <... class="grid"> to an element, it will have all the styling applied to it as defined inside of .grid {...} below.
*/
.grid {
	/*
		By setting the 'display' property to a value of 'grid', we are setting the container to use CSS grid system for its layout.
	*/
	display: grid;
}





/*
	Below the selector we have is specified as '.grid.add-gutters'. This means that to have this styling applied in our HTML, we have to select an element that has the classes of BOTH 'grid' and 'add-gutters'. This might look like the following in our HTML:

	<div class="grid add-gutters"> - This would have the styling below applied to it.
	<div class="add-gutters"> - This would NOT have the styling below applied to it.

	While we could have our .grid class specify the gutters, we may in some cases want a grid structure that does not included gutters. By having a separate class specifically for adding gutters we can apply (or not) this styling easily in our HTML.
*/
.grid.add-gutters {
	
	/*
		To add gutters between the columns and rows of our grid structure we have the 'grid-column-gap' and 'grid-row-gap' properties. These will add space between columns or rows of our grid as you specify. In this case, we are adding 1rem of spacing between columns and 0.25rem of spacing between rows.
	*/
	grid-column-gap: 1rem;
	grid-row-gap: 0.25rem;
}






/*
	Based on resizing the window and watching when the content could re-organize, we can determine when to add media queries (@media) to adjust the page layout accordingly. In this case, we measured that around 820 pixels was a good point at which to switch our two-column content to be placed next to one another. Because we want to ensure that the page responds to changes in font-size (and applies media queries accordingly), we use the base font size of 16 pixels to calculate our rem units in this case: 820/16px = 51.25rem

	The 'min-width' condition for our media query states that when the width of the browser window is at or larger than 51.25rem, apply the specified styling. Any styling that appears in a @media statement will ONLY apply when the condition is met.
*/
@media (min-width: 51.25rem) {
	

	/*
		We are applying the same styling to both our two and four-column grids as we know at this media query this is enough room for two columns across, but not yet four.
	*/
	.grid.two-column, .grid.four-column {
		/*
			The CSS Grid system allows us to define both columns and rows for our 'template' to follow. For this we use the 'grid-template-columns' and 'grid-template-rows' properties with the 'fr' unit to assign the structure of our grid. The 'fr' unit refers to a 'fraction'. Because we want a three-column grid we assign the following:

			grid-template-columns: 1fr 1fr; - Here the two values - '1fr 1fr' - indicate that we want two columns, each equal in width - 1 fraction (fr) of 2. The browser will automatically determine what the actual width of these columns are.

			grid-template-rows: auto; - Because we don't necessarily know how many rows our grid structure will be in this case, we are not assigning a specific number of rows to our grid structure.
		*/
		grid-template-columns: 1fr 1fr;
		grid-template-rows: auto;
		
		/*
			The 'grid-auto-flow' property allows us to have the browser automatically place items to fill in our grid structure as necessary. In this case by specifying the value of 'row' we are telling the browser to fill-in the rows of our grid and add new rows as necessary.
		*/
		grid-auto-flow: row;
	}

}



/*
	In this case, we measured that around 1120 pixels was a good point at which to switch our four-column items to be placed next to one another instead of on top of one another. The calculation in this case is 1120/16px = 70rem

	The 'min-width' condition for our media query states that when the width of the browser window is at or larger than 70rem, apply the specified styling. Any styling that appears in a @media statement will ONLY apply when the condition is met.
*/
@media (min-width: 70rem) {
	
	.grid.four-column {
		/*
			grid-template-columns: 1fr 1fr 1fr 1fr; - Here the four values - '1fr 1fr 1fr 1fr' - indicate that we want four columns, each equal in width - 1 fraction (fr) of 4. The browser will automatically determine what the actual width of these columns are.

			grid-template-rows: auto; - Because we don't necessarily know how many rows our grid structure will be in this case, we are not assigning a specific number of rows to our grid structure.
		*/
		grid-template-columns: 1fr 1fr 1fr 1fr;
		grid-template-rows: auto;
		grid-auto-flow: row;
	}
}



/* THIS IS IN MAIN.CSS IN THE TUTORIAL FILES */
body {
	font-family: "Fira", Verdana, sans-serif;
	margin: 1rem;
	font-size: 1.25rem;
}

h1 {
	font-size: 3rem;
	margin-bottom: 0;
}

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

h3 {
	font-size: 1.6rem;
	margin-bottom: 0;
}

p, ol, ul {
	max-width: 40rem;
}

img {
	height: auto; 
	max-width: 100%;
	border-width: 0.1rem;
	border-style: solid;
	border-color: black; 
}

figure {
	margin: 0;
}

figcaption {
	font-style: italic;
}

a {
	color: rgb(200,0,0);
	transition-property: color;
	transition-duration: 0.5s;
}

a:active, a:hover, a:focus {
	color: rgb(50,0,0); 
	text-decoration: none;
}

code, samp {
	display: block;
	background-color: rgb(230,230,230);
	padding: 0.5rem;
}

.nav-main-item {
	display: inline-block;
	color: white;
	background-color: rgb(250,100,75);
	font-size: 1.5rem;
	padding: 0.25rem 0.5rem;
	text-decoration: none;

	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);
}

.bg1 {
	background-color: purple;
}

.bg2 {
	background-color: green;
}

.bg3 {
	background-color: blue;
}

              
            
!

JS

              
                
              
            
!
999px

Console