by Elizabeth Castro
I, Michael Parker, own this book and took these notes to further my own learning. If you enjoy these notes, please purchase the book!
- Elements are block or inline; block elements are displayed on new lines, while inline elements are not. This is the difference between
divandspan. - If you save your document in UTF-8, and declare it as such when serving it, you don't have to use character references like
©, with the exception of&for&. - XHTML requires the
DOCTYPEandhtml,head, andbodyelements in a document, and that every attribute has a value (e.g.noshade="noshade"). - If a browser finds a
DOCTYPE, then it uses standards mode; otherwise, it uses quirks mode. - A stylesheet has multiple rules. Each rule is composed of a selector, and between the curly brackets, a collection of declarations separated by semicolons. Each declaration has a property name, followed by a colon, and one or more values.
- CSS uses inheritance, specificity, and location to resolve rule conflicts:
- Many CSS properties affect not only the elements defined by the selector but also their descendants; this is called inheritance.
- If multiple rules apply to an element and conflict with each other, the more specific rules take precedence (e.g. a rule for an id overrides a class); this is called specificity.
- If this cannot decide which rule to apply, the last rule takes precedence; this is called location.
- When declaring the length of an element,
emis usually equal to the element's font size.
- Declare the page encoding in UTF-8 with
<meta http-equiv="content-type" content="text/html; charset=utf-8" />in the<head>element. Starting the document with<?xml version="1.0" encoding="UTF-8"?>will put IE6 into quirks mode. - The
idattribute automatically turns the element into an anchor, to which you can directly link. - A
spanhas no inherent formatting, while adivonly has the line break as inherent formatting. - You can use the
titleattribute to add a tool tip to anything; to suppress IE from using alt as a tooltip for images, use an empty title, i.e.title="".
- The
ttelement forces monospaced font; when displaying computer code, thecodeattribute is equivalent, but gives semantic meaning. - To strikethrough text, use the
delelement. - Use the
abbroracronymtag (if the abbreviation an be pronounced as a word) with thetitleattribute to explain their contents when hovering.
- If a browser is asked to show a color outside its range, it can mix two colors (called ditherhing) or show the closest available one (called shifting).
- The web-safe or browser-safe colors are the 216 colors that are not reserved by the browser and are supported by both Windows and Mac.
- Each frame in GIF format is limited to 256 colors, although these colors can be selected from a much larger palete.
- The PNG format is not limited to 256 colors, and like GIF is lossless and allows for transparency, but unlike GIF cannot have multiple frames.
- The JPEG or JPG format, typically used for photos, uses lossy compression and so originals should be saved in a format like TIFF.
- Add the
widthandheightattributes to theimgelement so that the browser can display the text while the image loads. - Use the
brelement with theclearattribute so that the following elements will not display until the specified margin (left,right, orall) is clear.
- Open a link in a new window by adding
target="_blank"to the link element. - Links with the same value for
targetwill all open in the same window. - Add the
tabindexattribute between0and32767to links to define a custom tab order; links with the same index value are accessed in the order in which they appear.
- A descendant selector of the form
A Bmatches when an elementBis an arbitrary descendant of some ancestor elementA. - The universal selector is
*, andA * Bmatches aBelement that is a grandchild or later descendant of anAelement. - The child selector of the form
A > Bmatches when an elementBis a child of anAelement. - The adjacent sibling selector of the form
A + Bmatches when an elementBis an adjacent sibling of anAelement. - The attribute selector
A[foo]matches anyAelement with attributefooset;A[foo~="bar"]restricts to onlyfooattributes containingbar, andA[foo="bar"]restricts to onlyfooattributes equal tobar. - Pseudo-classes select markup; the selector
A:first-childchooses only theAelements that are the first child of some parent element. - When setting link properties, i.e. the
atag, define them in the orderlink,visited,focus,hover,active. - Pseudo-elements select content; the selector
A:first-lineorA:first-letterchooses the first line (which can change as the browser resizes) or first letter of anyAelement.
- To change the marker, set the
list-style-typeproperty with valuesdisc,circle,square,decimal,upper-alpha,lower-alpha,upper-roman, orlower-roman. - To use a custom image, set the
list-style-imageproperty with a value as the image URL; the image should be no larger than 15 x 15 pixels. - The
dlelement begins a definition list, suited for glossaries, where terms are indtand definitions are indd, alternating as necessary. - When styling nested lists, the selectors should reflect the types of nested lists, e.g.
ol liandol ol li.