Reading Notes
CSS (Cascading Style Sheets) alows developer to set rules to specify how content and layout should appear
CSS Rule governs how content of specified elements should be displayed
p {font-family: Arial;}
p
= Selector indicates which elements rule applies tofont-family: Arial;
= Declaration how the elements should be styled
{}
and is made up of two parts: a property and a value;
External CSS Allows a single seperate file to contain all of the style information for a multipage website
<link>
*element placed inthe html document in the <head>
element telling the browswer where to find the CSS<link href="urlofcss" type="textorcss" rel="stylesheet" />
href
indicates the path to the CSS filetype
specifies type of doc being linked to text or cssrel
specifies relationship between html page and file linked to, should be stylesheet when linking to CSS fileInternal CSS *can use CSS in html page by placing them within a <style>
element, usually inside a <head>
element
<head>
<title>Using Internal CSS</title>
<style type="text/css">
body {
font-family: arial;
background-color: rgb(185,179,175);}
</style>
</head>
CSS Selectors
Selector | Meaning | Example
— | — | —
Universal Selector | applies to all elements in doc | *{}
Type Selector | matches element names | h1, h2, h3 {}
Class Selector | matches element whose class attribute has value specified after the .
| .example {}
ID Selector | matches element whose id attribute has value specified after the #
| #example {}
Child Selector | matches the element that is a direct child of another | li>a {}
Descendant Selector | matches element that is a descendant of another specified element | ` p a {}
Adjacent Sibling Selector | matches and element that is the next sibling of another |
h1+p {}
General Sibling Selector | matches element that is a sibling of another, does not have to be directly preceding element |
h1~p {}`
Cascading Rules
!important
after any rule to indicate that it should be treated as more important than other rules that apply to the same element
p b { color: blue !important:}
Inheritance style properties that are inheritable can be given to all children of an element by default
inherit
in the value of the propertyOnline tools that allow developer to test CSS appearance in multiple virtual browsers and or OS
CSS Bug Fixes and Tools
Color the color:
property allows you to specify text color in an element
rgb(100,100,90)
#
, example: #ee3e80
DarkCyan
CSS Comments developer notes that will not effect the code
/*comment*/
Background Color background color is set to transparent by default, most browsers show white, but not always
body {
background_color: rgb(200,200,200):}
Online Color Picking Tool Color Scheme Designer
Opacity allows developer to set the opacity of an element and its children, values from 0.0 to 1.0
rgba
, example: rgba(231,112,56,0.5)
HSL Colors defines a color in three terms: hue, saturation, and lightness