On Github auremoser / web-intro-2
In this class we'll review some basics of web development with HTML/CSS, languages for writing content to the web.
A website is a way to present your content to the world, using HTML and CSS to present that content & make it look good.
A paragraph is your content
<p>A paragraph is your content</p>
A paragraph is your content
<tagname>Stuff in the middle</tagname>
<p>This is a sample paragraph.</p>
<br/> <img/>
<p lang="fr">C'est la vie</p> <img src="my.picture.jpg"/>
CSS = Cascading Style Sheets
CSS is a "style sheet language" that lets you style the elements on your page.
CSS works in conjunction with HTML, but is not HTML itself.
selector { property: value; }
A block of CSS is a rule block.
The rule starts with a selector.
It has sets of properties and values.
A property-value pair is a declaration.
Declarations: property and value of style you plan use on HTML element.
selector { property: value; property: value; property: value; }
p { property: value; }
Selects all paragraph elements.
img { property: value; }
Selects all image elements.
#footer { property: value; }
Selects all elements with an id of "footer".
<p id="footer">Copyright 2011</p>
The associated HTML.
.warning { color: red; }
Selects all elements with a class of "warning".
<p class="warning">Run away!</p>
The associated HTML.
p em { color: yellow; }
Selects all em elements that are within a paragraph
<p>This is <em>important.</em></p>
The associated HTML.
But how do people use this REALLY?
Even though HTML is the structure and CSS is the design, some HTML elements have default styles
Examples include:
margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;
list-style: none;
Some sizes that are good to know about
Wrappers are a good way to center content if the screen width is wider than your content.
.wrapper{ width: 100%; max-width:1400px; margin: 0 auto; }
Test out the practice files
<a href = "#section">Go to Section!</a>
<a name= "section"></a>
In addition to applying css to elements, classes and ids, you can apply css on certain events. Most notably, hover
.turn-blue:hover{ background-color: lightblue; color: grey }
<div class = "turn-blue">I will only turn blue on hover</div>I will only turn blue on hover
The world of HTML has progressed beyond Times New Roman and Arial
Yay!
How do we use new and cool fonts?
Use font from outside sources (like Google Web Fonts)
http://www.google.com/webfonts
In our example, we use Audiowide, Quicksand and Lato
<link href="http://fonts.googleapis.com/css?family=Audiowide|Quicksand:300,400,700|Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic" rel="stylesheet" type="text/css">What does that do?
Download fonts locally
In our example, we downloaded 'Entypo'
To use it, add the following to css:
@font-face { font-family: 'EntypoRegular'; src: url('font/Entypo-webfont.eot'); src: url('font/Entypo-webfont.eot?#iefix') format('embedded-opentype'), url('font/Entypo-webfont.woff') format('woff'), url('font/Entypo-webfont.ttf') format('truetype'), url('font/Entypo-webfont.svg#EntypoRegular') format('svg'); font-weight: normal; font-style: normal; }
Using the fonts
body{ font-family: 'Lato', Arial, sans-serif; }
learn by editing the practice files
Formally, HTML5 is the W3C’s specification for the next version of HTML.
Informally, people use "HTML5" to refer to a whole set of new web standards and abilities:
Too much to cover in our time together
But here are some highlights:
Gives some old elements semantic meaning and separates them from presentation (e.g. b, i, strong, em)
<!DOCTYPE html>
Minimum information required to ensure that a browser renders using standards mode
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Give meaning to structure
<div id="header"></div>
<div class="nav"></div>
<div id="footer"></div>
<header></header>
<nav></nav>
<footer></footer>
<body> <div id="header"> <h1>Hi, I'm a header!</h1> <div id="nav"> <ul> <li><a href="foo">foo</a></li> <li><a href="bar">bar</a></li> </ul> </div> </div> <div id="main"> <div class="article">foo</div> <div class="article">bar</div> </div> <div id="footer">Hi, I'm a footer!</div> </body>
<body> <div id="header"> <h1>Hi, I'm a header!</h1> <div id="nav"> <ul> <li><a href="foo">foo</a></li> <li><a href="bar">bar</a></li> </ul> </div> </div> <div id="main"> <div class="article">foo</div> <div class="article">bar</div> </div> <div id="footer">Hi, I'm a footer!</div> </body>
<body> <header> <h1>Hi, I'm a header!</h1> <nav> <ul> <li><a href="http://www.foo.com">foo</a></li> <li><a href="http://www.bar.com">bar</a></li> </ul> </nav> </header> <section> <article>foo</article> <article>bar</article> </section> <footer>Hi, I'm a footer!</footer> </body>
HTML5 IE enabling script
<!--[if lt IE 9]> <script src="html5shiv.js"></script> <![endif]-->polyfill (n): a JavaScript shim that replicates the standard API for older browsers
Modify the site to use semantic HTML