Day 3 - PitchEngine/code-wyoming GitHub Wiki
#Day 3 Agenda
Go over the class's websites together.
- Nested lists
- Advantages
- Separate style from structure
- Reuse style
- Smaller html files
- Types of CSS
- Inline
- Embedded
- External
- Imported
- CSS Syntax Rules, selectors, declarations
- color & background-color properties
- color values
- hex
- hex shorthand
- rgb
- hsl
-
Create a simple webpage with a single heading and paragraph.
-
Set the heading to be "Inline CSS" and the paragraph to say "This paragraph inherits the styles applied to the body tag."
-
Finally, set some styles.
-
Give the body a background color of
#F5F5F5
and set its text's color to#008080
. -
Give the h1 the same properties, but swap the colors (set its background to
#008080
and color to#F5F5F5
) -
Launch the browser and check things out.
-
Add another paragraph, with a color of
#333
. Give it the text "This paragraph overrides the text color style applied to the body tag". -
Never use inline styles in this class ever, ever again.
- The
style
element.
- Create a copy of your multipage website project from yesterday.
- Open up the homepage.
- Use embedded styles to set a background-color and color for your body, h1, and h2.
-
font-family
- serif
- sans-serif
- monospace
- cursive
- fantasy
- Custom fonts
@font-face {font-family:SomeFont;, src:url(somefont.woff) format("woff");}
See also google fonts and font squirrel font-weight
font-style
line-height
text-align
text-decoration
text-transform
text-transform
white-space
- px, em, rem, %
font-size
text-indent
-
text-shadow
horizontal offset, vertical offset, blur radius, color
-
link
element - style.css
Create a page with a single paragraph, and an external stylesheet. Just set the background-color and the color of the body in the stylesheet. The trick here is making sure you're correctly using the <link>
element.
Move your embedded CSS into its own file, and create a link
element in each of your webpages that links to that file.
There are three steps to centering content in a webpage.
- Put your content in a div or other block element container.
- Set the width of that element to be less than the full width of the page.
- Set the left and right margins of the container to be automatically calculated to share extra space.
index.html
<body>
<main>
<h1>This is the heading</h1>
<p>This is your content</p>
</main>
</body>
style.css
main{
width: 80%;
margin-left: auto;
margin-right: auto;
}
Try making your browser wider and smaller, and then change your code so that the width
is 700px
and try resizing your browser again. We'll talk about what this difference means next time.
Tomorrow we're going to start using GitHub.
Read these articles so you have an idea of what it all means.
- Github for beginners
- How to install and configure git
- and here's a bunch of links with more to read
Get through the first article and I'm happy. Do your best to swing the second. Keep the third around for reference for later on.