Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
A website is a way to present your content to the world, using HTML and CSS to present that content & make it look good.
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.
HTML | + | CSS |
Structure | + | Style |
HTML | CSS | |||
+ | = |
All colored text, position, and size
3 ways
"Inline"
"Embedded"
"External"
<p style="color: red;">Some text.</p>
Uses the HTML attribute style.
Difficult to use in large projects
Not preferred.
<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
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
body {
color: red;
}
Shared resource for several pages.
Reduced file size & bandwidth
Easy to maintain in larger projects.
Preferred by web developers everywhere!
body {
color: red;
}
selector {
property: value;
}
A block of CSS code is a rule.
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.
Declarations end with a semicolon
Declaration groups are surrounded by curly brackets.
selector {
property-1: value-A;
property-2: value-B;
property-3: value-C;
}
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.
The "#" is how you tell CSS "this is an id."
The "." is how you tell CSS "this is a class name."
p em {
color: yellow;
}
Selects all em elements that are within a paragraph
<p>This is <em>important.</em></p>
The associated HTML.
Each property can have one or more comma separated values.
p {
color: white;
background-color: red;
font-family: Arial, sans-serif;
}
The color property changes the color of the text.
p { color: red; }
p { color: #ff0000; }
p { color: rgb(255, 0, 0); }
Color name
Hexadecimal value
RGB value
The 17 standard colors are:
The background-color property changes the color of the background.
p {
background-color: black;
}
p {
background-color: #000000;
}
p {
background-color: rgb(0,0,0);
}
These will be useful throughout the class.
Hint: not sure which colors to pick? Check out the color scheme designer.
The font-family property defines which font is used.
p {
font-family: "Times New Roman";
}
p {
font-family: serif;
}
p {
font-family: "Arial", sans-serif;
}
Specific font name
Generic name
Comma-separated list
The font-size property specifies the size of the font.
p {
font-size: 12px;
}
p {
font-size: 1.5em;
}
p {
font-size: 100%;
}
Pixels
"em"
Percentage
The font-weight property specifies the weight of the font.
p {
font-weight: normal;
}
p {
font-weight: bold;
}
p {
font-weight: 700;
}
p {
font-style: italic;
font-weight: bold;
font-size: 10px;
font-family: sans-serif;
}
OR
p {
font: italic bold 10px sans-serif;
}
Styles "cascade" down until changed
p {
color: blue;
font-family: 'Helvetica';
}
.warm {
color: red;
}
#special {
font-family: Arial;
}
<p>Paragraph</p>
<p class="green">Paragraph</p>
<p class="warm">Paragraph</p>
<p class="warm" id="special">Paragraph</p>
Many CSS properties have self-explanatory names:
You can add comments to your code that will not be seen by the browser, but only visible when viewing the code.
/* comments go here */
Comments can be used to organize your code into sections so you (or someone else) can easily understand your code. It can also be used to 'comment out' large chunks of code to hide it from the browser.
/* Main styles */
...
/* Styles for the footer */
...
CSS resets are used to set all styles to the same baseline
This is useful for eliminating inconsistencies across browsers
Continue adding CSS and HTML to your page as time allows.