Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
<p>This is a paragraph</p>
<head></head> and <body></body>
<a href="http://google.com/">this goes to google</a>
class
id
Two new HTML elements!
Style multiple elements the same way by grouping them together.
<span> creates an inline element.
<div> creates a block element.
<div>The quick <span class="brown">brown fox</span> jumps over the lazy duck?</div>
How do we write a 'class' selector in CSS?
<div>The quick <span class="brown">brown fox</span> jumps over the lazy duck?</div>
How do we center text?
How do we add a border to something?
.brown { color: brown; }
selector { text-align: center; }
selector { border: 2px solid black; }
The div tag is a great way to apply styles to a bunch of elements all at once.
The div tag is used everywhere to group elements together into sections.
For example:
<div class="right">
<p>These paragraphs can be styled together</p>
<p>By using a css rule for class "right"</p>
</div>
<p>But, I'll still be aligned to the left. I'm lonely :/ </p>
.right {
text-align: right;
}
<div class="right">
<a href="http://twitter.com/girldevelopit">Twitter!</a> |
<a href="http://facebook.com/girldevelopit">Facebook!</a>
</div>
<a href="http://girldevelopit.com">Website!</a> |
<a href="http://girldevelopit.tumblr.com">Blog!</a>
See? How fun!
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.
Changing the format of a link when you hover over it is accomplished by using pseudo-classes.
CSS pseudo-classes are used to add special effects to some selectors.
selector:pseudo-class
{
property: value;
}
Example:
a:link
{
text-decoration: none;
}
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 the CSS definition in order to be effective!
Note: a:active MUST come after a:hover in the CSS definition in order to be effective!
1. Start dividing your links and paragraphs into divs.
2. Add pseudo classes to your links.
3. Add text-align to your text.
Bonus: Add text-decoration: none; to one of your new link classes and see what it does.
Space between the border and the content
The edge around the box, specified as "thickness, style, color."
The transparent area around the box that separates it from other elements.
p { padding: 15px; }
10 pixels on top only
p { padding-top: 10px; }
10 on top, 5 on right, 3 on bottom, 5 on left
p { padding: 10px 5px 3px 5px; }
Four values
p { padding: top right bottom left; }
Two values
p { padding: top/bottom right/left; }
One value
p { padding: all; }
div { padding: 10px 20px 30px 40px; }
Easy to remember:
The box model is Trouble
The box model is TRBL
Top Right Bottom Left
Let's take a minute to try some if you all want!
p { padding: 30px 30px 30px 30px; }
A solid red border
p { border: 1px solid #ff0000; }
A thick dotted black top border
div { border-top: 4px dotted #000000; }
Two diļ¬erent border styles
address { border-top: 1px solid #ff0000; }
blockquote { border-bottom: 4px dotted #000000; }
p { border-width: 10px; }
p { border-style: dashed; }
p { border-color: #666666; }
You can specify each property separately, or all three together.
Padding:
p { padding: 10px 20px 30px 40px; }
15 pixels on all sides
p { margin: 15px; }
10 on top, 5 on right, 3 on bottom, 5 on left
p { margin: 10px 5px 3px 5px; }
10 pixels on top
p { margin-top: 10px; }
If a margin is set to auto on a box that has width, it will take up as much space as possible.
CENTERED
div { margin: auto; }
div { width: 300px; } /*Must have a specified width to work*/
FLUSH-RIGHT
div { margin-left: auto; }
div { margin-right: 5px; }
div { width: 300px; } /*Must have a specified width to work*/
1. Try to center your stuff using auto margin
2. Start adding padding, borders and margins to your divs to work more on styling
Cheat sheet:
div { padding: 10x 5px 10px 5px; }
div { margin: 15px; }
div { border: 3px dotted red;}
Try it on other block elements: p, blockquote, address
How would I add a border to the top and bottom of this paragraph?
<p id="my-paragraph">This is a really great paragraph</p>
#my-paragraph {
border-top: 1px solid black;
border-bottom: 1px solid black;
}