-
Notifications
You must be signed in to change notification settings - Fork 11
Lecture CSS
CSS: Cascading Stylesheets It tells a markup file (usually HTML) how it should be presented. This includes:
- Layouts and Grids
- Typography
- Color
- Positioning
- Image size
- Width/Height
http://dontfeartheinternet.com/05-from-scratch/
Recap:
- Inline
- Internal CSS
- Externally
We will be using external stylesheets, which is considered best practice for most website projects.
- Tell HTML where to look for styles
- Assign classes and/or IDs to HTML elements
- Reference those selectors in CSS file
- Add styles for each selector
Good news. You've already done this in A9. However, every single HTML file must be told where that CSS file lives.
<link rel="stylesheet" src="/assets/css/application.css">
IDs must be unique, meaning they can only be used one time per HTML document. Classes can be used on as many elements as you'd like.
Can't use spaces in your names. Use hyphens or underscores to breakup words. Whichever you choose, be consistent.
I tend to use:
- hyphens for classes
- underscores for IDs
This makes it easy to see at a glance if something is an ID or class.
- Classes are referenced by
. - IDs are referenced by
#
Think of it as selecting what you want and declaring what it will do.
Cascading stylesheets
-
Scope
-
Browser comes with different set of predefined styles [Tweet of devices] I've found the trick is to work with the quirks of each browser; not against them.
-
Chaining selectors
-
Targeting elements
-
max-width: 100%;
Resources:
- Warning explicit
body {
background-color: hotpink;
}