On Github robleto / Learning-HTML-and-CSS
An introduction to structure and style on the web
by Greg Robleto
Structure (HTML)
Style (CSS)
Functionality (JS)
Nearly all code has an output.
What is your output?
We are going to build this:
<a>
<a> ... </a>
<a href="http://www.fool.com">The Motley Fool</a>
<!DOCTYPE html> <html> <head> <title> ...</title> </head> <body> ... </body> </html>
p { ... } <!-- Type Selector --> p#sfr { ... } <!-- ID Selector --> p.grey { ... } <!-- Class Selector -->
color: #FFFF00;
font-size: <!-- Property Selector --> 16px; <!-- Value Selector -->
<h1>Welcome to The Motley Fool</h1> <h2>My Watched Stocks.</h2>
<p>The stock Apple is a great buy because...</p>
According to<em>Stock Advisor</em>, there is<strong>ONE</strong> great stock to buy...
p { font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 13px; font-style: italic; font-weight: bold;
line-height: 18px;
text-align: left; text-decoration: underline; text-indent: 0px; text-transform: uppercase; }
@font-face { font-family: 'Fool-Master'; src: url('Fool-Master.eot'); src: url('Fool-Master.eot') format('embedded-opentype'), url('Fool-Master.woff') format('woff'), url('Fool-Masterl.ttf') format('truetype'), url('Fool-Master.svg') format('svg'); }
<a href="aapl.html">Apple</a>
<a href="http://www.fool.com/stocks/aapl.html">Apple</a>
<a href="#aapl.html">Apple</a>
<a href="aapl.html" target="_blank">Apple</a>
a { color: #990000; } a:hover { color: #003300; } <!-- Link is hovered over --> a:visited { color: #000066; } <!-- Link has been visited -->
nav a { border-right: solid 1px #CCCCCC; } nav a:last-child { border-right: none; }
<ul> <li>Milk</li> <li>Eggs</li> <li>Bread</li> </ul>
<ol> <li>Beat the eggs and milk together</li> <li>Dip the bread into the batter</li> <li>Fry the breat until browned</li> </ol>Beat the eggs and milk together Dip the bread into the batter Fry the breat until browned
ol, ul { margin: 0px; padding: 0px; }
li { list-style-type: circle; list-style-image: url('checkbox.gif'); list-style-position: outside; }
For the next 30 minutes, apply the learnings to markup and style the typographical elements of the 404 page to look like this:
<img src="elvis.png" alt="The Motley Fool" />
img { width: 200px; height: 200px; }
img { float: left; margin-right: 10px; margin-bottom: 10px; }
footer { clear: both; }
<div class="image-wrapper"> <img src="elvis.png" alt="The Motley Fool" /> <p class="caption">The Motley Fool</p> </div>
<figure> <img src="elvis.png" alt="The Motley Fool" /> <figcaption>The Motley Fool</figcaption> </figure>
<canvas id="fool-logo" width="200" height="200"></canvas>
<audio src="marketfoolerypodcast.mp3"></audio>
<video src="investorbeat.mp4" width: 480" height="320"></video>
<label for="username">Username</label> <input type="text" name="username" id="username" placeholder="Fool">
Username:
<input type="email" ... > <input type="time" ...> <input type="date" ...> <input type="url" ...> <input type="phone" ... >
<input type="text" name="search" id="search" placeholder="Search"> <input type="button" value="Go">
input [type="text"] { ... } input [type="button"] { ... }
<textarea name="comments">Add your comments here</textarea>
Add your comments here
<input type="radio" name="day" value="Friday" checked> Friday <input type="radio" name="day" value="Saturday"> Saturday <input type="radio" name="day" value="Sunday"> Sunday
Friday Saturday Sunday
<input type="checkbox" name="day" value="Friday" checked> Friday <input type="checkbox" name="day" value="Saturday"> Saturday <input type="checkbox" name="day" value="Sunday"> Sunday
Friday Saturday Sunday
<select name="day"> <option value="Friday" selected>Friday</option> <option value="Saturday">Saturday</option> <option value="Sunday">Sunday</option> </select>
FridaySaturdaySunday
<select name="day" multiple> <option value="Friday" selected>Friday</option> <option value="Saturday">Saturday</option> <option value="Sunday">Sunday</option> </select>
FridaySaturdaySunday
<input type="button" value="Go">
<input type="submit" name="submit" value="Submit Form">
<input type="reset" name="reset" value="Reset Form">
<input type="hidden" name="tracking_code" value="abc_123">
<fieldset> <legend>Upload a File</legend> <input type="file" name="file"> </fieldset>Upload a File
<table> ... </table>
<table> <tr> ... </tr> <tr> ... </tr> </table>
<table> <tr> <td> ... </td> <td> ... </td> <td> ... </td> </tr> </table>
<table> <tr> <th> Company </th> <th> Ticker </th> <th> Price </th> </tr> <tr> <td> Apple </td> <td> AAPL </td> <td> $405.75 </td> </tr> <tr> <td> Google </td> <td> GOOG </td> <td> $810.54 </td> </tr> </table>Company Ticker Price Apple AAPL $405.75 Google GOOG $810.54
<tr> <td rowspan="2"> Berkshire Hathaway </td> <td> BRK-A </td> <td>$160,000.00 </td> </tr> <tr> <td> BRK-B </td> <td> $106.61 </td> </tr>Berkshire Hathaway BRK-A $160,000.00 BRK-B $106.61
<tr> <td colspan="2"> Data Points </td> </tr> <tr> <td> P/E Ratio</td> <td>17.82 </td> </tr>Data Points P/E Ratio 17.82
<!-- Depreciated version --> <td align="center"> Data Points </td> <!-- Preferred version using CSS --> td { text-align: center; }
<td valign="top"> Berkshire Hathaway </td>
<div> ... </div>
<header> ... </header> <nav> ... </nav> <article> ... </article> <section> ... </section> <aside> ... </aside> <footer> ... </footer>
body { background-color: #1a82f7; background-image: url(foolBG.png); background-position: 0px 0px; <!-- top & left --> background-repeat: no-repeat; }
div#main-container { background-color: #FFFFFF; }
div#header { /* fallback */ background-color: #1a82f7; background: url(images/linear_bg_2.png); background-repeat: repeat-x; /* Safari 4-5, Chrome 1-9 */ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727)); /* Safari 5.1, Chrome 10+ */ background: -webkit-linear-gradient(top, #2F2727, #1a82f7); /* Firefox 3.6+ */ background: -moz-linear-gradient(top, #2F2727, #1a82f7); /* IE 10 */ background: -ms-linear-gradient(top, #2F2727, #1a82f7); /* Opera 11.10+ */ background: -o-linear-gradient(top, #2F2727, #1a82f7); }
div { margin: 20px; border: 6px solid #ccc; padding: 20px; width: 400px; height: 100px; }
Width: 492px = 20px + 6px + 20px + 400px + 20px + 6px + 20px
Height: 192px = 20px + 6px + 20px + 100px + 20px + 6px + 20px
For the rest of class and/or homework, finish building this: