Jon Rumsey

An online markdown blog and knowledge repository.


Project maintained by nojronatron Hosted on GitHub Pages — Theme by mattgraham

Notes from Duckett HTML and JS Books

Notes taken from Ducketts HTML and CSS book while skimming Chapters on HTML Images, CSS Color and Text.

Chapter 5: Images (pg.94)

Images can add interest to your website. The book suggests the following [Duckett, pg.97]

Be relevant Convey information Convey the right mood Be instantly recognizable Fit the color palette

Stock photos are available, usually for a price, from many sources, Duckett suggests a few:

iStockPhoto
GettyImages
Veer
SXC
Fotolia

Configure your website with separate folder(s) for the site images.

Img Tag

<img src="url" alt="text for screen readers" 
  title="text to display when hovered over (tooltip)"
  height="" width="" />

Note: Either height or width is helpful, but using both or neither could cause unexpected results.
Note^2: More commonly, dimensions of an image are defined in CSS.

Image Placement

Block-level elements following an <img> element will always appear on a new line.
When <img> is within a block-level element, inline elements will flow around the image.

Note: AVOID using align properties with settings: left, right, top, middle, or bottom.

Image Formatting

Use the following formats:

Use a sensible image size:

Same dimensions of the target dimensions within the website.

Set the units of measurement to the screen:

Commonly used tools, and those suggested by the author, in no particular order [Duckett, pg.108]

Adobe Fireworks Pixelmator PaintShop Pro Paint.net Photoshp Pixlr SplashUp Ipiccy

Animations

Adobe Photoshop has tools to create animated GIFs.
Animated GIFs are made of strung-together static images.
Animated GIFs can increase the time it takes for a web page to load fully.
Usually reserved for simple animations, not high-quality images or motion effect.

Transparency and Shadows

Transparent GIFs:

"If the transparent part of the image has straight edges and it is 100% transparent (that is, not semi-opaque), you can save the image as a GIF (with the transparency option selected)." [Duckett, pg.118]

Transparent PNGs:

"If the transparent part of the image has diagonal or rounded edges or if you want a semi-opaque transparency or a drop-shadow, then you will need to save it as a PNG." [Duckett, pg.118]

Note: Not all browsers, especially older ones, fully support transparent PNGs.

Captioning Images

Use the following elements to enclose images and caption them:

<figure> <figcaption>

Older browsers ignore these tags but will still display the content within and around them.

Chapter 11: Color (pg.246)

Color is another "grabber" feature of a web page - it can really get the attention of your users.

Specifing Colors

Several ways to specify colors:

These color specifiers can be applied to:

Color Terminology and Contrast

Colors are displayed on computer monitors by using a color or hue, and saturation and brightness:

Color: RGB, Hex, or Color Name Hue: An alternate to Color; think of the colors of a rainbow.
Saturation: The amount of grey that is in the color.
Brightness: The amount of black that is in the color.

Contrast: Text can become illegible in low-contrast styling arrangements. Ensure the contrast is high enough to make the content stand out without being too "strong" for the message or theme of the website.

Opacity: New in CSS3, it can be set using a value between 0.0 and 1.0, or using a 4th setting in rgb(r, g, b, opacity).

CSS3 HSL Colors and HSLA

HSL is composed of:

HSLA includes one more:

HSL and HSLA Usage:

body {
  background-color: hsl(0, 0%, 78%);
}
p {
  background-color: hsla(0, 100%, 100%, 0.5);
}

Work Around For Old Browsers: Since the final element setting will take precedence, and older browsers do not recognize the opacity setting in the RGB property specification, enter the backward-compatiby rgb(r, g, b) setting first, followed by the newer rgb(r, g, b, opacity) setting, the latter of which will be applied by newer browsers, and ignored by older ones.

Chapter 12: Text (pg.264)

Two groups of properties for controlling text style:

  1. Directly affect the font itself: size, typeface, bold, italicized.
  2. Other non-font-specific alterations: color, spacing, etc.

Controlling fonts and styles of text directly impact the beauty of your website.

Typefaces

Font adjustments

Font Limitations

Font Properties and Settings

font-family

font-size

font-weight

font-style

text-decoration

Spacings

text-align

One and only one of these:

vertical-align

Used when adding text near an 'img' tag. Moves text up or down within the box neighboring another element.

text-indent

Indents the first line of text.
Accepts px units.

text-shadow

There are four properties to set on this rule, e.g. [Duckett, pg.288]:

p.one {
  //
  text-shadow: 1px 1px 0px #000000;
}
  1. Shadow fall left or right.
  2. Shadow fall top or bottom.
  3. Blur amount to apply (optional).
  4. Shadowing color.

Note: Possible browser support problems with this rule.

First Letter or Line

:first-letter, :first-line

These 'pseudo-elements' apply to the first-letter of a line or the first-line of a block of text.

Usage:

p.pOne: first-letter{
  font-size: 2em;
}

:link, ':visited

Usage:

a:link {
  color: blue;
}
a:visited {
  color: red;
}

Responding to Users

:hover, :active, :focus

Define what happens to elements with certain user actions.

Attribute Selectors

Existence: Attribute matcher element[string]: p[class] selects all p elements with a 'class' attribute.
Equality: Matches element[comparer] selects elements with 'attribute=string'.
Space: Matches elements that contain a space-separated word element[attribute ~= string].
Prefix: Matches attribute by starting string element[attribute ^= "string"].
Substring: Matches attribute by substring element[attribute *= "string"].
Suffix: Matches attribute with ending value element[attribute $= "string"].