Jeseekia Vaughn | @MetaDevGirl | @GDIdet | jeseekia@metadevgirl.com
Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
I am a Frontend Web Developer expanding my skills to become a software developer. I am a senior Mechanical Engineering student at Wayne State University. I also instruct and volunteer with Girl Develop It and am passionate about technology education. Follow me on twitter @MetaDevGirl
Tell us about yourself.
Why do you think this code isn't working?
WRONG:
<a href="index.html" Home Page</a>
CORRECT:
<a href="index.html">Home Page</a>
Don't forget to make sure all your brackets are enclosing your tag name and tag attributes.
Why do you think this code isn't working?
WRONG:
<ul>
<li Milk/>
<li Eggs/>
<li Cocoa Puffs/>
</ul>
CORRECT:
<ul>
<li>Milk</li>
<li>Eggs</li>
<li>Cocoa Puffs</li>
</ul>
Every list item gets its own set of opening and closing li tags, lists are not self-closing tags.
We're here to help!
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.
<head>
of your HTML file:
<link rel="stylesheet" type="text/css" href="styles.css" />
Our index.html file now links to our styles.css document.
The <head>
section of our HTML looks like this:
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
<title>Title of the page </title>
</head>
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.
The color
property changes the color of the text.
p {
color: red;
color: #ff0000;
color: rgb(255, 0, 0);
}
Color name
Hexadecimal value
RGB value
The background-color property changes the color of the background.
p {
background-color: black;
background-color: #000000;
background-color: rgb(0,0,0);
}
styles.css
filebody
a background color (#c4da9a)a
tagsh1
tag
body {
background-color: #c4da9a;
}
h1 {
background-color: #00A9B4;
color: #ffffff;
}
a {
color: #8B0036;
}
The font-family property defines which font is used.
p {
font-family: "MySpecificFont", "Times New Roman", serif;
}
We write our fonts in a font stack: a hierarchical, comma-separated list:
The font-size property specifies the size of the font.
p {
font-size: 12px;
font-size: 1.5em;
font-size: 100%;
}
Units of measurement:
p {
font-style: italic;
font-weight: bold;
font-size: 10px;
font-family: sans-serif;
}
OR
p {
font: italic bold 10px sans-serif;
}
p {
font-family: "Trebuchet MS","Lucida Grande","Lucida Sans Unicode","Lucida Sans",Tahoma,sans-serif;
}
h1 {
background-color: #00A9B4;
color: #ffffff;
font-family: Georgia,Times,"Times New Roman",serif;
}
p em {
color: yellow;
}
Selects all em elements that are within a paragraph
<p>This is <em>important.</em></p>
The associated HTML.
li
s we have inside our ol
differently than the ones inside our ul
.
ol li {
font: 25px sans-serif;
}
Just like in HTML, we can use CSS comments to organize or "comment out" our code.
Example:
/* Navigation */
nav ul li {
background-color: red;
}
/* Links */
a {
color: orange;
}
/*ol li a {
color: blue;
}*/
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>
Shared resource for several pages.
Reduced file size & bandwidth
Easy to maintain in larger projects.
Preferred by nerds everywhere!
Styles "cascade" down until changed
p{
color:blue;
font-family: 'Helvetica';
}
p{
color:red;
}
p{
font-family: Arial;
}
Another way to think about it: bottom rules override top rules.
One more: the last thing you heard is what you'll remember.
Many CSS properties have self-explanatory names:
Why do you think this code isn't working?
WRONG:
h1 {
color: green
font-face: serif
}
CORRECT:
h1 {
color: green;
font-face: serif;
}
Don't forget semi-colons after CSS properties.
Why do you think this code isn't working?
WRONG:
body {
color: grey;
p {
font-size: 30px;
}
}
CORRECT:
body {
color: grey;
}
p {
font-size: 30px;
}
All CSS selectors and properties must be self contained. Selectors cannot be inside the { } of other selectors.
Let's right-click, "Inspect Element" & look at some code!