Some "rules"
All the files for your site should be stored within the same folder.
This includes:
Note: File names should not include spaces or special characters. File names ARE case sensitive.
HTML (HyperText Markup Language)is the code that allows us to build websites
The web is mostly used for 2 things:
To organize information in a logical way To display information in a logical & aesthetically pleasing way<!DOCTYPE html> <html> <head> </head> <body> </body> </html>
<img src="my_picture.jpg" /> <a href="http://girldevelopit.com">GDI</a> <section id="copyright">© GDI 2013</section> <section class="important">Remember!</section>
Links have three components
<a href="http://www.girldevelopit.com" title="Girl Develop It Homepage">GDI</a>
The <a> tag surrounds text or images to turn them into links
Links can have attributes that tell the link to do different actions like open in a new tab, or launch your e-mail program.
<a href="http://bit.ly/NDTPQJ" target="_blank">GDI SLC Meetup</a>
Link opens in a new window/tab with target="_blank"
<a href="mailto:saltlakecity@girldevelopit.com">E-mail us!</a>
Link opens mail program by inserting mailto: directly before the email address.
CSS = Cascading Style Sheets
CSS is a "style sheet language" that lets you style the elements on your page.
CSS is works in conjunction with HTML, but is not HTML itself.
3 ways
"External"
"Embedded"
"Inline"
<head> <link rel="stylesheet" href="styles.css"> </head>
Shared resource for several pages.
Reduced file size & bandwidth
Easy to maintain in larger projects.
Preferred by coders everywhere!
<head> <style type="text/css"> p { color: blue; font-size: 12px; } </style> </head>
Inside <head> element.
Uses <style> tag.
Can only be used in one html file
<p style="color:red;">Some text.</p>
Uses the HTML attribute style.
Difficult to use in large projects
Not preferred.
The edge around the box, specified as "thickness, style, color."
A solid red border
border: 1px solid #ff0000;
A thick dotted black top border
border-top: 4px dotted #000000;
Two different border styles
border-top: 1px solid #ff0000; border-bottom: 4px dotted #000000;
Sets the width of an element.
Does not include padding or borders. These add to the width.
body { width: 900px; }
Sets the height of an element.
Does not include padding or borders. These add to the height.
body { height: 900px; }
So far, we have mostly seen "block" elements. They appear on the next line, like paragraphs
<p>, <h1>, <ul>, <li>, almost everything else
There are also "inline" elements. They appear on the same line that they are written on.
"Floating" an element moves it, in the normal flow, as far to the left or right of its parent element as possible.
Above a <blockquote> is floated to the left, allowing text to wrap around it on the right
Any other elements, such as paragraphs or lists, will wrap around the floated element.
.float{ float:left; width:200px; background:yellow; }
If you want two block level elements to be side by side, you need to float both elements. One left, and one right.
Always specify a width when floating an element, otherwise the element is likely to take up the whole page and not appear floated.
clear: right; clear: left; clear: both;
If you had an image, div, etc. floated left, and you did not want the paragraph to appear next to it, you would add clear: left; to the paragraph.
.float{ float:left; width:50px; background:yellow; } .clear-left{ clear:left }
The font-family property defines which font is used.
p { font-family: "Times New Roman"; font-family: serif; font-family: Arial, sans-serif; }
Specific font name
Generic name
Comma-separated list
Only have to use quotation marks ("") when the name has spaces
The font-size property specifies the size of the font.
p { font-size: 12px; font-size: 1.5rem; font-size: 100%; }
Pixels
"rem" or "em"
Percentage
p { font-style: italic; font-weight: bold; font-size: 10px; font-family: sans-serif; }
OR
p { font: italic bold 10px sans-serif; }
Space between the border and the content
Adds to the total width of the box.
20 pixels* on top only
padding-top: 20px;
20 pixels on right only
padding-right: 20px;
20 pixels on bottom only
padding-bottom: 20px;
20 pixels on left only
padding-left: 20px;
*Like font-size, you can also use em, rem, or percentages
15 pixels on all sides
padding: 15px; /* All sides */
20 on top, 15 on right, 13 on bottom, 25 on left
padding: 20px 15px 13px 25px; /* Top, Right, Bottom, Left */
10 on top/bottom, 45 on right/left
padding: 10px 45px; /* Top/Bottom Right/Left */
padding: 10px 20px 30px 40px;
The transparent area around the box that separates it from other elements.
One side
margin-top: 10px; /* 10 pixels on top */
All sides
margin: 15px; /* 15 pixels on all sides */
Top, Right, Bottom, Left
margin: 10px 5px 3px 5px; /* 10 on top, 5 on right, 3 on bottom, 5 on left */
Top/Bottom, Right/Left
margin: 10px 20px; /* 10 on top/bottom, 20 on right/left */
If a margin is set to auto on a box that has width, it will take up as much space as possible.
CENTERED
margin: auto; width: 300px;
FLUSH-RIGHT
margin-left: auto; margin-right: 5px; width: 300px;
Aligned left (default)
text-align: left;
Aligned right
text-align: right;
Aligned center
text-align: center;
Justifying all of the text
text-align: justify;
Unitless (multiply this number by the font-size)
line-height: 1.5;
Using rem or em's
line-height: 1.5em;
Using percentages
line-height: 150%;
Span is used to apply a specific style inline
.yellow { color: yellow; }
<p>Paragraph with <span class ="yellow">yellow</span> text.</p>
Paragraph with yellow text.
The color property changes the color of the text.
p { color: red; /* Color name */ color: #ff0000; /* Hexadecimal value */ color: rgb(255, 0, 0); /* RGB value */ }
The 17 standard colors are: aqua, black, blue, fuchsia, gray, grey, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.
The background-color property changes the color of the background.
p { background-color: black; background-color: #000000; background-color: rgb(0,0,0); }
CSS pseudo-classes are used to add additional functionality to some selectors.
a:link { color:#FF0000; } /* unvisited link */ a:visited { color:#00FF00; } /* visited link */ a:hover { color:#FF00FF; } /* mouse over link */ a:active { color:#0000FF; } /* selected link */
Note: a:hover MUST come after a:link and a:visited in order to be effective!
Note: a:active MUST come after a:hover in order to be effective!
Underlined
text-decoration: underline;
Overline
text-decoration: overline;
Line through your text
text-decoration: line-through;
Shorthand*
text-decoration: underline wavy red;
Div is a block level element. Each new div is rendered on a new line. It has no semantic meaning. Used to group elements to format them with CSS.
<div> <p>Content<p> <p>Content<p> </div>
<div id="header-group"> <header> <h1>Main Heading<h1> </header> <nav> <ul><li>Home</li></ul> </nav> </div>
Apply IDs and Classes to divs to control their styles with CSS.