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">
		<title>My Less Hideous Page</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 it after our normalize.css file.
		-->
		<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>

		<!--
			We have started to add classes to our HTML elements to help style each of them differently. It is a good practice to get into instead of styling the elements by their element names (i.e. selecting by just nav or a) as it means it will be easier to track down what styling is being applied to which element.
		-->
		<nav class="nav-main">

			<a href="#robot" class="nav-main-item">See a Robot</a>
			<a href="#comments" class="nav-main-item">Comment on Robots</a>

		</nav>


		<section id="robot">

			<h2>See a Robot</h2>

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

			<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>


			<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>Leave your comments on the evils of robots:</p>

			<form method="post" action="#">

				<label for="form-name">Name:</label>
				<input type="text" id="form-name" placeholder="Jane Doe">

				<label for="form-subject">Subject:</label>
				<input type="text" id="form-subject" placeholder="A title for your comment">

				<label for="form-comment">Comment:</label>
				<textarea id="form-comment" placeholder="Please place comment here"></textarea>
				<input type="submit" value="Submit your comment">

			</form>

		</section>


	</body>
</html>

              
            
!

CSS

              
                /* THIS IS IN MAIN.CSS IN THE TUTORIAL FILES 
	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: "Fira", 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: 1.25rem;
}



/*
	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;
}

h3 {
	font-size: 1.6rem;
	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%;

	/* 
		Below we are defining the border of our images, specifically the width, style (solid, dotted, dashed, etc), and colour.
	*/
	border-width: 0.1rem;
	border-style: solid;
	border-color: black; 
}



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);
	/*
		CSS transitions make it very easy to create smooth transitions for different CSS properties. In this case, we are first specifying that we want to transition the 'color' property (with transition-property), and the specifying the duration of 0.5 seconds (with transition-duration). Note that you have to have another state (i.e. :hover, :focus) for the element for it to actually make use of the transition.
	*/
	transition-property: color;
	transition-duration: 0.5s;
}



/* 
	The :active, :hover and :focus are pseudo-states for the element. In this case, we are saying when the anchor tag is 'active' (being clicked on), 'hover' (being hovered over), and 'focus' (selected by keyboard, i.e. tab), it should apply the styling specified.
*/
a:active, 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;
}

code, samp {
	/*
		The display property allows us to change how an element renders. By default, our .nav-main-item <a> (anchor) element displays as inline. To have it behave more like a button, we need to set it to display as either a block or inline-block element. These allow .nav-main-item to have a defineable height and width.
	*/
	display: block;
	background-color: rgb(230,230,230);

	/*
		While margin sets the space outside of our border box, padding is the space between the border and the content itself. In this case we are setting the padding on all sides to 0.5rem.
	*/
	padding: 0.5rem;
}



/*
	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.25rem 0.5rem;

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

	transition-property: background-color;
	transition-duration: 0.5s;
	/*
		Unlike our prior transition statement, here we are also adding a type of easing using the transition-timing-function property.
	*/
	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);
}


/*
	By setting our labels and textareas to display as a 'block' element, they will bump down the next content (form fields or buttons) to the next line because they span 100% of the width by default.
*/
label, textarea {
	display: block;
}


/*
	We can use margins to create space between the different form fields.
*/
input {
	margin-bottom: 1rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console