HTML & CSS Reference

What's New?

I've written out a Step-by-Step guide on embedding a PDF within the document. Comments and suggestions appreciated.

Compare and contrast: the use of monospace font for code, as used here: HTML At-a-Glance

...with the use of a single, sans-serif font, as shown here: HTML At-a-Glance2 (sans-serif)

Ignore the 'Top Dogs Run Wild' and follow this link: Top of the Box

Here to clear the floats

  • TEMPLATES of Most Likely Forgotten Things.
    • HTML Document Templates
      • Basic
      • 'Full Monty'
    • The 'Clearfix' Method
    • Nesting Lists
      • Within Lists
        • Within Lists
          • To right back here, or farther!
        • And then back again...
      • ...like this...
    • ...and this...
    • Getting 'lorem ipsum'
      • In Sublime Text
      • Elsewhere

Here to clear the floats

Top

Further Reading, Research, Resources

An Authoratative Guide to HTML5 Elements, Attributes, and so Very Much More:
https://www.w3schools.com/tags/default.asp Go to...
Inspirational CSS:
http://www.csszengarden.com Go to...

Begin at the Beginning...

Before using this reference, take a moment to understand six important terms: the HTML element, (and the element's possible attribute and its value); along with the three parts of a CSS Rule: the selector, the property, and its value.

THE HTML 'ELEMENT'

		<p> ... </p>
		opening tag  |  closing tag
		content
	

The example above, in bold, is an HTML element. Like many HTML elements, it has an opening tag <p> and a closing tag </p>.

HTML elements can be further sub-divided, but don't worry about these just yet. As you progress, these sub-divisions will become more meaningful. They will help hone in your search for that elusive element name you just can't remember. For the moment, just click on the 'HTML Elements (Tags)' and scroll down to find the one you're looking for.

THE CSS RULE

		selector {property: value;}
		e.g.   p { padding:  10px;}
	
The CSS rule is a little more complex. It has three parts to remember: the selector, property and value:
The selector is often no more than an HTML element (without the angle brackets), as in the p example above;
The property part of a CSS rule;
The value part is usually easy to figure.
Top

Document Structure

	<!DOCTYPE html>
	<html>

		<head>
			<meta charset="utf-8">
			<title>...</title>
			<link rel="stylesheet" href="url" type="text/css">

			<style type="text/css">
		/*	selector {property: value;}	*/
			</style>

			@import url("url")
		</head>

		<body>
			<header>...</header>
			<element style="property: value;">text</element>
			<nav>...</nav>
			<article>...</article>
			<aside>...</aside>
			<div>...</div>
			<footer>...</footer>
		</body>

	</html>
	
Top

HTML DOCUMENT TEMPLATES

Basic

Copy and paste the following content into a plain text editor (TextEdit for Mac, NotePad for PC, making sure it ends with a .html extension) to create a basic HTML page you can add content to

  <html>

  <head>
    <title>...</title>
  </head>

  <body>
    <h1>...</h1>
    <p>...</p>
  </body>

  </html>
	
Top

Basic Publishable Template

  <!DOCTYPE html>
  <html>
  
  <head>
    <meta charset="utf-8">
    <title>...</title>
  </head>
  
  <body>
  </body>
  
  </html>
	
Top

The 'Full Monty' with Embedded Style Sheet and 'Clearfix' Method.

 <!DOCTYPE html>
 <html>

 <head>
   <meta charset="utf-8">
   <title>...</title>
   <style type="text/css">

  /* CSS rules here: selector {property: value;} */

  /* The "Clearfix" Method - Just add class="group" to any
 HTML parent element with floated children: */
 .group:before,
 .group:after {
 content: "";
 display: table;
 }

 .group:after {
 clear: both;
 }

 .group {
 zoom: 1;
 }
 </style>

 </head>

 <body>
 </body>

 </html>
	

Linking to an External CSS File

In the root directory, alongside index.html, create a directory/folder and name it 'css'. Within the directory, create a plain text document and name it 'screen.css'. (You can give it any name you like, but make sure it's plain text and ends with a .css extension.

Now we'll add the necessary code in the <head> of the index.html document:

<link rel="stylesheet" href="css/screen.css">

After you've saved both documents, you can begin writing your CSS styles into screen.css. Or, if you've created any embedded CSS styles within the head of index.html, copy and paste them into screen.css, but omit the start and close <style> tag from your selection. When you've successfully done that, remove the content from index.html.

Top

Help!

Dummy Text: 'Lorem Ipsum'

'Lorem ipsum' is dummy text used to quickly and effectively simulate the look of actual page content.

Any internet search will yield many sites offering 'lorem ipsum' generated text, which you can copy and paste directly into your project. Here's one site which, at the time of writing, not only ranked highest on a Google search, but didn't require you to create a Log-in account: www.lipsum,com. It also includes an informed and interesting background and history on 'lorem ipsum'.

If you want a generator on your desktop, there are free downloads available. And for Mac users, there's at least one free Widget you can download from the Apple Store—I know, because I downloaded it. If you're using Sublime Text, generating 'lorem ipsum' is easy: just type in 'lorem'—without the apostophes—and press Tab. If you want some 'Lorum ipsum' right now, here's paragraph I've just generated in Sublime Text:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

HTML (& CSS) Comments.

Add an HTML Comment

I'm always forgetting these bloody things, and they're so indispensable, too! Whenever you want to comments, section headings, explanations—anything you like—into into your HTML, but you don't want it to be visible enclose it between the following, just like this:



There you go: you can't see a thing in the browser, can you? But here's what's written. It's visible now because I've converted the 'less than' and 'greater than' angle brackets into character entities thus rendering the HTML invalid.

<!-- Write anything you like here. -->

Add a CSS Comment

You can add similar invisible comments into your CSS documents using the following:

/* Write anything you like here. */

So, you may be wondering, how come it can be seen? Because, this is an HTML document, Silly!

Top

Reference Guide & Abbreviations

Top

The Named Colors

Black
#000000

Gray
#808080

Silver
#C0C0C0

LightGray
#

White
#FFFFFF

Maroon
#800000

Red
#FF0000

Purple
#800080

Fuchsia
#FF00FF

Green
#008000

Lime
#00FF00

Olive
#808000

Yellow
#FFFF00

Navy
#000080

Blue
#0000FF

Teal
#008080

Aqua
#0000FF

Orange
#FFA500

HTML

Top

Special Character Entities

For a comprehensive listcomprehensive list of Character Entities.

Top

HTML Elements

IMG and Attributes

Document Elements

Top

Text Elements

Top

Lists

Top

Unordered List

	<ul>
		<li>...</li>
		<li>...</li>
	</ul>
	

Example:
Shopping List

In the following HTML mark up, the list items could appear in any order. As written here, however...

<ul>
     <li>Bread</li>
     <li>Butter</li>
     <li>Eggs</li>
     <li>Bacon</li>
</ul>

...they render so in the browser window...

...and make a delicious bacon-and-egg sandwich!

Top Top

Ordered List

	<ol>
		<li>...</li>
		<li>...</li>
	</ol>

	

Example:
Four Strokes of the 4-stroke Engine

The engine strokes happen in a particular order. The 'ordered list' demonstrates this...

<ol>
     <li>Induction (Suck)</li>
     <li>Compression (Squeeze)</li>
     <li>Ignition (Bang)</li>
     <li>Exhaust (Fart)</li>
</ol>

...and renders so in the browser.

  1. Induction (Suck)
  2. Compression (Squeeze)
  3. Ignition (Bang)
  4. Exhaust (Fart)

Description/Definition List

	<dl>
		<dt>...</dt>
		<dd>...</dd>
		<dt>...</dt>
		<dd>...</dd>
	</dl>
	

Example:
List Element

The following HTML mark up...

<dl>
     <dt>The <ul> tag:<dt>
     <dd>Stands for 'unordered list'<dd>
     <dt>The <li> tag:<dt>
     <dd>Stands for 'list item'<dd>
     <dt>The <ol> tag:<dt>
     <dd>Stands for 'ordered list'<dd>
     <dt>The <dl> tag:<dt>
     <dd>Stands for 'description' or 'definition list'<dd>
     <dt>The <dt> tag:<dt>
     <dd>Stands for 'description' or 'definition term'<dd>
     <dt>The <dd> tag:<dt>
     <dd>Stands for 'description definition'<dd>
<dl>

...renders so in the browser window.

The <ul> tag:
Stands for 'unordered list'
The <li> tag:
Stands for 'list item'
The <ol> tag:
Stands for 'ordered list'
The <dl> tag:
Stands for 'description' or 'definition list'
The <dt> tag:
Stands for 'description' or 'definition term'
The <dd> tag:
Stands for 'description definition'
Top

<a href=“url”>...</a>

Up a Folder

url eg “../picture.jpg”

Down a Folder

url eg “folder/picture.jpg”

Relative URL

“page.html”

Absolute URL

“http://www.website”

Root Relative URL

“/folder/page.html”

Fragment Identifier

<element id=“...”>...</element>

Link to Fragment

<a href=“#fragmentID”>...</a>

<a href=“page2.html#fragmentID”>...</a>

Top

IMAGES

Quick Reference Table for Image and Object Elements

IMG and Attributes

Placing an Image

The img Element

Here is the bare-bones image element <img>. Notice it doesn't have a closing tag, between which we could, if we chose, write some content for the browser to display. In fact, the img element is called an 'empty' or 'replaced' element because it never contains content of its own. Instead, we place within it an attribute (and an attribute value, always a url) which then 'sources' (and is replaced by) the actual content. Below is the img element with the src attribute and value.

  <a src="url">
	

All we need do now is replace the url value with an actual, real value. As we discovered in 'Links', urls come in different guises: relative; root relative; and absolute. I'm a tad short of 'decent' images on my computer, so for demonstration purpose only, I'll use an absolute url.

Here's one I nicked earlier:

Vessel A

And here is the source code:

  <img src="http://www.chkent.co.uk//images/VesselA-011.jpg" alt="Vessel A">
	

(I always wondered why http: was followed by two dashes, //. It took a while to figure how to nick one of your images, and just by chance I wondered if a double-dash might work. It did. Hooray!)

To complete the img element, and make it standards-compliant, we are required to include the alt="text" ('alternative') attribute. This should be a short description of the image. If for some reason the browser cannot find the image—the user may be using a text-only or speech browser device—

  <img src="url" alt="text">
	

By the way, we don't have to give the alt attribute a value for us to remain compliant with the standards. There will be circumstances when it is best not to give a value. For example, if the image is too small to fit in the alternative text, the browser won't bother. In such circumstances it's best not to uselessly bloat the download file. All we need do is include the alt attribute, but omit any value:

  <img src="url" alt="">
	

(Jennifer Niederst gives, as an example of when not to include an alt value an image whose alt text would be "red line", because it's not at all useful, and only slows down the document processing. She also points out, that users with spoken browsering devises would find it frustrating. In such case, include the two double-quotes, but don't include a value, as in the example above.

The Width and Height Attributes

The width andheight, although not required, may be useful, especially if you have alote of images, or the images are large. With these measurements, the browser can layout the page while the images download. Without them, the browser must reconfigure the page as each file is downloaded.

Here's how to include the width and height attributes (and, by the way, if you're not sure what the measurements are, just drag and drop the image file into a browser window—they will appear in the browser's title bar):

  <img src="url" alt="text" width="number" length="number">
	

Two Tips in Image Loading

1. Always reuse the same image, rather than have multiple copies of the same image. A root relative url can achieve this.

2. For large images, place a small preview-sized image, with description, dimensions and file size. Let the user decide if they want to wait for the download.

Images Placed in a Flow of Text

Images Used as Links

Image Maps

Relative Linking Conventions for src and href Attributes

Examples

The following image placed with the <img> element.

The next with the <object> element

IMG and Attributes
 <object type="application/pdf" data="images/attributes-full-size.pdf" width="497" height="285">...</object>
	

Example URL

“picture.jpg”
	.gif
	.png
(For more on URLs, see ‘Links’.)

(See also: Embedding a PDF)

Nutshell, pgs 634-637, Portable Document Format (PDF)

Linking to a PDF - Step-by-Step Guide

The .pdf will open, either in the present window (replacing all your content); or in a seperate window. If you want it to open in a seperate window, include the target attribute in your <a href="url">...</a> like this,

<a href="url" target="name">...</a>

Type in the following markup.
 <a href="images/bass-sunny-afternoon.pdf" target="display">Bass Part for Sunny Afternoon</a>
		
It will appear like this:
Bass Part for Sunny Afternoon

IMAGEs and OBJECTs

Embedding a PDF

(See also: Linking to a PDF)

A Step-by-Step Guide to Embedding a PDF

Element Attribute
<object>...</object> Core (id  class  style  title)

data="url"

type="..."

height="..."

width="..."

In a previous Step-by-Step, we used the anchor a element, along with its href attribute, to create a link to a PDF document. We then used the target attribute to open it in a seperate window. Here, we'll go through the steps necessary to embed a PDF within the content of the page we're actually working on. And for this we'll need the object element.

In the table above, along with the Core attributes, are the three, or possibly four, attributes needed to accomplish this. The height and width are self-explanatory, so we'll concentrate on the other two. But before we begin, make sure you have a PDF document ready, with the necessary .pdf suffix.

Begin by typing in the object opening and closing tags. These can be included either inside or outside a paragraph element. It makes little difference. I'm typing them within.

<object></object>

The data attribute provides the url of the PDF document, whilst the the type attribute specifies the kind of media file being used. (By the way, the W3Schools suggests that only one—either one!—of these attributes needs to be included. But if only one is required, that one must surely be the data because otherwise there'd be no url provided.) So let's now add that to our code. I'm linking to the sunny-afternoon.pdf, which resides in my 'images' directory. You must put in the correct url link to your PDF file.

<object data="images/sunny-afternoon.pdf"></object>

When we Save and Refresh, you should see something like this on your screen:



If you don't, then maybe your browser requires the type attribute? We're going to add that next, anyway—even though, according to W3Schools, it may not be strictly necessary.

Within the code, enter the type attribute, and its value, just as it's written below. I'm going to place it all in front of the previous entry—however (please note) not because this is the required order of entry. It isn't. Any order will do.

<object type="application/pdf" data="images/sunny-afternoon.pdf"></object>



If you still cannot see the the PDF, and you're absolutely sure your code is right, consult the sidebar, "For Even Older Browsers" for some additional coding solutions.

Let's now include the width and height. All of the sources I consulted said these had to be entered as pixels. However, whilst I found this to be true of the height value, I found the width also responded perfectly well to percentage values. Of course, that may just be browser (Safari) specific, but I'm going to include a percentage value here, just to show it can be done. If it doesn't work for your browser, just convert to pixels.

All of this Step-by-Step guide has been contained within a div tag with a width-value of 900px. Further, all of the markup is included within to p element. It didn't need to be. Within that p element, I'll complete the code:

<object width="100%" height="1265px" type="application/pdf" data="images/sunny-afternoon.pdf"></object>

After a Save and Refresh, you should now have a PDF happily embedded within your document content, comfortably taking up all of the available width of your containing vessel, like this (if it is within your p tag—and please scroll down to the text beyond):

Or, like this, if is not—again, please scroll down to the text beyond:

Try experimenting with percentage values beyond 100%, or beyond the pixel dimensions of your containing vessel. It's really quite interesting! I'll explore them more, here, later.

The 'Audio' Element

Adding audio the Udemy way

The 'Video' Element

Adding video the Udemy way

Top

Tables

Top

Tables

HTML Table Elements at a Glance.
Element Tag Element Name
<table>...</table> table
<tr>...</tr> table row
<td>...</td> table data
<th>...</th> table header
<caption>...</caption> caption
<thead>...</thead> table head
<tbody>...</tbody> table body
<tfoot>...</tfoot> table footer
<col>...</col> column
<colgroup>...</colgroup> column group

The table above is just quick reminder of all ten HTML elements available for use in building tables. Only the first three are essential, but you'll almost certainly wish to include the fourth element, the Table Header. A comprehensive list of all these Elements, and their corresponding Attributes and Values, is in preparation. Please scroll down and take a peek at the progress made so far.

The table, below, lists all of the HTML elements associated with the table element, and their attributes and attribute values. It doesn't set out to explain them, just list them -- I haven't a clue what most of them do, myself!

Above the list is a 'Mini Menu'. Use it to locate the element you're looking for. It will jump to it. Within each HTML Element group is a return to the 'Mini Menu' or a return to 'Top'. I hope they're self-explanatory. If they're not, and you end somewhere you didn't expect, hit the Browser's "back" button.

Top

Table Elements, Attributes, Values and Events

HTML Element Attribute Attribute Values Events
<table attr="...">...</table>


Mini Menu   Top
id ="text"
class ="text"
style ="text"
title ="text"
border ="number"
cellpadding ="pixels, percent"
cellspacing ="pixels, percent"
frame ="void|above|below|hsides|
lhs|rhs|vsides|box|border"
rules ="all|cols|groups|none|rows"
summary ="text"
width ="number, percent"
height ="number, percent"
<tr attr="...">...</tr>


Mini Menu   Top
CORE (id, class,
style, title)
="text"
align ="left|center|right|justify|
char"
char ="character"
charoff ="lengtht"
valign ="top,middle,bottom,baseline"
<td attr="...">...</td>


Mini Menu   Top
Core (id, class,
style, title)
="text"
abbr ="text"
align ="left|right|center|justify|char"
axis ="text"
char ="character"
charoff ="length"
colspan ="number"
headers ="id references"
rowspan ="number"
scope ="row|col|rowgroup|colgroup"
valign ="top|middle|bottom|baseline"
<th attr="...">...</th>


Mini Menu   Top
Core (id, class,
style, title)
="text"
abbr ="text"
align ="left|right|center|justify|char"
axis ="text"
char ="character"
charoff ="length"
colspan ="number"
headers ="id references"
rowspan ="number"
scope ="row|col|rowgroup|colgroup"
valign ="top|middle|bottom|baseline"
<caption attr="...">...</caption>


Mini Menu   Top
Core (id, class,
style, title)
="text"
align ="top|bottom|left|right"
The caption immediately follows the opening table
tag and precedes all other content.
<thead attr="...">...</thead>

<tbody attr="...">...</tbody>

<tfoot attr="...">...</tfoot>


Mini Menu   Top
Core (id, class,
style, title)
="text"
align ="left|center|right|justify|char"
char ="character"
charoff ="length"
valign ="top|middle|bottom|baseline"
<col attr="...">...</col>


Mini Menu   Top
Core (id, class,
style, title)
="name"
align ="left|center|right|justify|char"
char ="character"
charoff ="length"
span ="number"
valign ="top|middle|bottom|baseline"
width ="pixels, percent, n*"
<colgroup attr="...">...</colgroup>


Mini Menu   Top
Core (id, class,
style, title)
="..."
align ="left|center|right|justify|char"
char ="character"
charoff ="length"
span ="number"
valign ="top|middle|bottom|baseline"
width ="pixels, percent, n*"
Top

Basic Table Template with Optional Caption

		<table>
			<caption align="...">...</caption>
			<tr>
				<th>...</th>
				<th>...</th>
				<th>...</th>
			</tr>
			<tr>
				<td>...</td>
				<td>...</td>
				<td>...</td>
			</tr>
		</table>
		
Top
Top

Frames

Top

Forms

Top

HTML Elements by Type

BLOCK LEVEL ELEMENTS

Top

GENERIC (NON-SEMANTIC) ELEMENTS

CLASS & ID

(Learning, see ‘Not just for divs,’ sidebar, pg 87)

Top

DOCUMENT STRUCTURE

Top

SEMANTIC STRUCTURE

Top

NAVIGATION

Top

SEMANTIC INLINE ELEMENTS

(Learning, pgs. 81—83)

Top

PRESENTATIONAL

(Learning, pgs. 84—85. Preferred CSS alternatives, pg. 85) Top

VARIOUS

Top

HTML COMMENT

Top

SECTIONS

Lecture #21: <section> used as alternative to <h1> to <h6>.

Top

HTML Elements, Attributes and Events0

  • References:
  • Nutshell: pgs. 641-683, Appendix A. Condensed but comprehensive summary of HTML elements, arranged alphabetically, with explanations & examples.
  • Learning: Chpt. 5, Marking Up Text, pgs. 71-94; HTML elements at a glance, pg. 94.

HTML Elements (Alphabetical)

  • References:
  • Nutshell: pgs. 641-683, Appendix A. Condensed but comprehensive summary of HTML Elements arranged, as here, alphabetically, with explanations & examples.
  • Internet: Index DOT Html: The Advanced HTML (and CSS) Reference. This is a very comprehensive list of HTML Elements and Attributes. There is a similarly comprehensive list of CSS Selectors, Properies and Values. Its only downside is its age, 2003 being the last update.

HTML Elements, Attributes and Events1

HTML Element Attributes Events
<a attr>...</a> href="..." onblur
class="..." onclick
id="..." ondblclick
name="..." onfocus
height="..." onmousedown
width="..." onmouseup
target="..." onmouseover

Examples

<a id="a-example" href="http://www.musictutors.net/" target="screen">MusicTutors</a>.

And here is the above anchor in action. It will open a new window or tab: MusicTutors.

Top

HTML Elements, Attributes and Events2

HTML Element Most Useful
Attributes
A
<a>...</a>
<a href="url">...</a>
<a name="...">...</a>
<abbr>...</abbr>
<acronym>...</acronym>
<address>...</address>
<applet>...</applet>
<area>...</area>
B
<b>...</b>
<base>...</base>
<basefont>...</basefont>
<bdo>...</bdo>
<bgsound>...</bgsound>
<big>...</big>
<blink>...</blink>
<blockquote>...</blockquote>
<body>...</body>
<br> (XHTML: <br />)
<button>...</button>
C
Top

List

Mini Menu

|  A  |  B  |  C  |  D  |  E  |  F  |  H |  I  | J | K  |  L  |  M  |  N  |  O  |  P  |  Q / R  |  S  |  T  |  U / V  |  W / X  |  !  | 

  • A

  • <a>...</a>
  • <a href="url">...</a>
  • <a name="...">...</a>
  • <abbr>...</abbr>
  • <acronym>...</acronym>
  • <address>...</address>
  • <applet>...</applet>
  • <area>...</area>
  • B

  • <b>...</b>
  • <base>...</base>
  • <basefont>...</basefont>
  • <bdo>...</bdo>
  • <bgsound>...</bgsound>
  • <big>...</big>
  • <blink>...</blink>
  • <blockquote>...</blockquote>
  • <body>...</body>
  • <br>     <br />
  • <button>...</button>
Top    Back
  • C

  • <caption>...</caption>
  • <center>...</center>
  • <cite>...</cite>
  • <code>...</code>
  • <col>...</col>
  • <colgroup>...</colgroup>
  • <comment>...</comment>
  • D

  • <dd>...</dd>
  • <del>...</del>
  • <dfn>...</dfn>
  • <dir>...</dir>
  • <div>...</div>
  • <dl>...</dl>
  • <dt>...</dt>
  • E

  • <em>...</em>
  • <embed>...</embed>
Top    Back
  • F

  • <fieldset>...</fieldset>
  • <font>...</font>
  • <form>...</form>
  • <frame>...</frame>
  • <frameset>...</frameset>
  • H

  • <head>...</head>
  • <hr>    <hr />;
  • <html>...</html>
  • <hx>...</hx>
  • I

  • <i>...</i>
  • <iframe>...</iframe>
  • <ilayer>...</ilayer>
  • <img attr>    <img />
  • <img src="url">
  • <inlineinput>...</inlineinput>
  • <input>...</input>
  • <input type="...">...</input>
  • <ins>...</ins>
  • <isindex>...</isindex>
Top    Back
  • K

  • <kbd>...</kbd>
  • <keygen>...</keygen>
  • L

  • <label>...</label>
  • <layer>...</layer>
  • <legend>...</legend>
  • <li>...</li>
  • <link>...</link>
  • <listing>...</listing>
  • M

  • <map>...</map>
  • <marquee>...</marquee>
  • <menu>...</menu>
  • <meta>
  • <meta charset="...">
  • <multicol>...</multicol>
Top    Back
  • N

  • <nextid>...</nextid>
  • <nobr>...</nobr>
  • <noembed>...</noembed>
  • <noframes>...</noframes>
  • <nolayer>...</nolayer>
  • <noscript>...</noscript>
  • O

  • <object>...</object>
  • <ol>...</ol>
  • <optgroup>...</optgroup>
  • <option>...</option>
  • P

  • <p>...</p>
  • <param>...</param>
  • <plaintext>...</plaintext>
  • <pre>...</pre>
Top    Back
  • Q/R

  • <q>...</q>
  • <rb>...</rb>
  • <rbc>...</rbc>
  • <rp>...</rp>
  • <rt>...</rt>
  • <rtc>...</rtc>
  • <ruby>...</ruby>
  • S

  • <s>...</s>
  • <samp>...</samp>
  • <script>...</script>
  • <select>...</select>
  • <small>...</small>
  • <sound>...</sound>
  • <spacer>...</spacer>
  • <span>...</span>
  • <spell>...</spell>
  • <strike>...</strike>
  • <strong>...</strong>
  • <style>...</style>
  • <sub>...</sub>
  • <sup>...</sup>
Top    Back
  • T

  • <table>...</table>
  • <tbody>...</tbody>
  • <td>...</td>
  • <textarea>...</textarea>
  • <tfoot>...</tfoot>
  • <th>...</th>
  • <thead>...</thead>
  • <title>...</title>
  • <tr>...</tr>
  • <tt>...</tt>
  • U/V

  • <u>...</u>
  • <ul>...</ul>
  • <var>...</var>
  • W/X

  • <wbr>...</wbr>
  • <xml>...</xml>
  • <xmp>...</xmp>
  • !

  • <!DOCTYPE>
  • <!DOCTYPE html>
  • <!--[downlevel-hidden]-->
  • <!--[downlevel-revealed]-->
  • <!--...-->
Top    Back
Top

HTML Elements, Attributes and Events

HTML Element Attributes Events
<a attr>...</a> href="..." onblur
class="..." onclick
id="..." ondblclick
name="..." onfocus
height="..." onmousedown
width="..." onmouseup
target="..." onmouseover
accesskey|charset|coords|contenteditable|contentmenu|download|dir| hreflang|hidden|id|lang|media|name|onabort|onautocompleteerror| onblur|oncancel|oncanplay|oncanplaythrough|onchange|ping|rel|rev|shape|style| target|type|tabindex|title|translate
Examples:
<a id="a-example" href="http://www.musictutors.net/" target="screen">MusicTutors</a>.

And here is the above anchor in action. It will open a new window or tab: MusicTutors.

Surely the 'attribute' of an HTML element must, like the CSS rule, have a 'property' and a 'value'? The 'href' attribute to an anchor tag doesn't stand alone. It also requires a 'value':

	     _______attribute________
	    |                        |
	 <a href="www.musictutors.net">Music Tutors</a>
	    |     |
	property  value
Top

CSS

CSS PROPERTY REFERENCE

CSS Values

Top

TEXT PROPERTIES

  • color

  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight

  • letter-spacing

  • line-height

  • text-align
  • text-decoration
  • text-indent
  • text-shadow
  • text-transform

  • vertical-align

  • white-space

  • word-spacing
Top

LIST PROPERTIES

  • (Nutshell pg 406)
  • list-style
  • list-style-image
  • list-style-position (inside, outside)
  • list-style-type
Top

PADDING, BORDER, & MARGIN PROPERTIES

  • box-shadow

  • border
  • border-radius

  • border-top/-right/-bottom/-left
  • border-color
  • border-top-color/-right-/-bottom-/-left-

  • border-style
  • border-top-style/-right-/-bottom-/-left-

  • border-width
  • border-top-width/-right-/-bottom-/-left-

  • box-sizing

  • outline
  • outline-color
  • outline-style
  • outline-width

  • padding
  • padding-top
  • padding-right
  • padding-bottom
  • padding-left

  • margin
  • margin-top
  • margin-right
  • margin-bottom
  • margin-left
Top

BACKGROUND PROPERTIES

  • background
  • background-attachment
  • background-clip
  • background-color

  • background-image
  • background-origin
  • background-position
  • background-repeat
  • background-size
Top

PAGE LAYOUT PROPERTIES

  • bottom
  • top

  • clear

  • clip

  • display

  • float

  • height
  • width
  • max-height
  • max-width

  • left
  • right

  • overflow

  • position

  • visibility

  • z-index
Top

Animation, Transform & Transition Properties

Top

Table Properties

Top

Miscellaneous Properties

Top
Top

CSS Properties and Values

Property (Inherit ✓ ✗) Values
Text Properties
color Keyword: black|gray/grey|silver|lightgray|white|
maroon|red|purple|fuchsia|green|lime|olive|yellow|
navy|blue|teal|aqua|orange

Hex.: #rrggbb [e.g. #000000 (black, abbr. #000) or #ffffff (white, abbr. #fff)]

RGB: rgb(r, g, b) [examples:
rgb(0, 0, 0) (black) or rgb(255, 255, 255) (white)
rgb(0%, 0%, 0%) (black) or rgb(100%, 100%, 100%) (white)
rgb(hex. values) see above]

RGBA: rgba(r, g, b, a) [where a (transparency) = .01 to 1]

(It would be interesting to see if .01 was the most transparency we could achieve. What if we used .001 or beyond?)
(And what is Safari's support like for the 140 keywords for color? The last comment was in Coral. This is in Darkseagreen)
font Shorthand: font-style, -variant, -weight, line-height, [optional and in any order, followed by (mandatory, and in this order)] font-size, generic

The generic families: serif, sans-serif, monospace, cursive, fantasy

line-height follows font-size and slash, thus: font-size/line-height

Example:
font-family font, font, font-family

Example: font-family: "Lucida Grande", Arial, sans-serif;
font-size Keyword: xx-small|x-small|small|medium|large|x-large|xx-large
larger|smaller [browser default is medium]

Example: font-size: x-large;
font-style Keyword: italic|oblique|normal

Example: font-size: normal;
font-variant Keyword:small-caps|normal

Example: font-variant: small-caps;
font-weight Keyword: bold|normal [CSS provides other keywords, but only these work]

Example: font-weight: bold;
letter-spacing Values: em|px [most common]

Examples:
letter-spacing: -1px;
letter-spacing: 2em;
line-height
text-align Keyword: left|center|right|justify
text-decoration Keyword: underline|overline|line-through|blink

Example: text-decoration: underline overline;
text-indent
text-shadow
text-transform
vertical-align Keyword: baseline|sub|super|top|text-top|middle|bottom|text-bottom
Table cell: top|middle|bottom|baseline

Examples:
vertical-align: top;
vertical-align: -5px;
vertical-align: 75%;
white-space
word-spacing
List Properties
list-style Shorthand: lsi, lsp(and/or), lst
list-style-image
(lsi)
url|none
list-style-position
(lsp)
inside|outside
list-style-type
(lst)
dic|circle|square|decimal|decimal-leading-zero|upper-alpha|lower-alpha|upper-roman|lower-roman|lower-greek|none
Padding, Border, and Margins
box-shadow
border
border-radius
border-top, -right, -bottom, -left
border-color
border-top-color, -right-color, -bottom-color, -left-color
border-color
border-top-style, -right-style, -bottom-style, -left-style
border-width
border-top-width, -right-width, -bottom-width, -left-width
box-sizing content-box|padding-box|border-box
outline
outline-color
outline-style
outline-width
padding
padding-top, -right, -bottom, -left
margin
margin-top, -right, -bottom, -left
Padding, Border, and Margins
background
background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-repeat
background-size
Page Layout Properties
bottom
clear
clip
display
float
height
left
max-height
max-width
min-height
min-width
overflow
position
right
top
visibility
width
z-index
Animations, Transform and Transition Properties
keyframes
animation
animation-name
animation-duration
animation-timing-function
animation-delay
animation-iteration-count
animation-direction
animation-fill-mode
animation-play-state
transform
transform-origin
transition
transition-property
transition-duration
transition-timing-function
transition-delay
Table Properties
border-collapse
border-spacing
caption-side
empty-cells
table-layout
Miscellaneous Properties>
content
cursor
opacity
orphans
page-break-inside
widows
Top

Miscellaneous

Brad Schiff's Sublime Text Tutorials on YouTube.

Top

Summary of Tutorials

Sublime Text Introduction (Tutorial #1)

Multiple undos:
Mac: cmd + z
PC: ctrl + z

Multiple Insertion of Text Cursor

Multiple insertions of the text cursor to type/edit in different places simultaneously:
Mac: cmd + click (at each location)
PC: ctrl + click

Multiple Edits of Same Word

Edit same word in multiple locations - highlight word - ST outlines all other instances - then
Mac: cmd + d
PC: ctrl + d
selects following instance each time. To skip an instance, simply hold down cmd and select instances beyond, then continue with + d.

Click-Dragging Cursor Up/Down

To place cursor at the same location (e.g. beginning of a list) over several lines:
Mac: alt + click drag (up/down)
PC: shift + click drag

Placing Cursor at Uneven Line Ends

Place cursor at the end of several uneven lines - the previous, but with cursor dragged up/down at extreme right of any line ending
But BETTER WAY! - select all of the text, then,
Mac: cmd + shift + L
PC: ctrl + shift + L
This makes each line an editable line - then, to place cursor at the end of each line,
Mac: click left arrow
PC: click left arrow

Moving Cursor to Beginning/End of Multiple Lines

With multiply cursors still in place, to move to the beginning of each line, and then return back to the end,
Mac: cmd + left/right arrow
PC: ctrl + 'Home' (and presumable 'End')

Adding HTML Opening and End Tags

Adding opening and closing HTML tags to content - highlight the content, then press,
Mac: cntl + shift + W
PC: alt + shift + W
This automatically wraps the content in a default <p>...</p> - type in the desired HTML element. What you type automatically becomes both start and end tags.

Adding HTML Start/End to Individual Items in a List

To add the start and end tags to each item in a long list of items, select all the items in the list. Simply repeating the previous instruction would only add a start and end tag to the entire selection. To add a start and end tag to each individual item, use the previous
Mac: ctrl + shift = L
PC: alt + shift + L
making each line editable, then,
Mac: ctrl + shift + W
PC: alt + shift + W

Top

Sublime Text Command Palette (Tutorial #4)

The Command Palette,
cmd + shift + p
Start typing "enco..." "Encode Special Characters"

Top

GUITAR TAB USING <PRE>...</PRE> TAG

The bass guitar tab, below, uses only the <h4>...</h4> and <pre>...</pre> (pre-formatted) HTML elements to display all of the TAB -- previously created in TextEdit:

ALL MY LOVING (BASS GUITAR)

	A B A B C D A B C E

	[A](Verse)
	   F#m          B            E            C#m
	||:------------|------------|------------|------------|
	  |4--2--1-----|------------|------------|------------|
	  |---------4--|2--0--------|------2-----|4--4-----4--|
	  |------------|------4--2--|0--4-----4--|------4-----|
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	   A            F#m          D            B7
	  |------------|------------|------------|------------|
	  |---------2--|4--4-----4--|0--0--0--0--|------------|
	  |0--0--4-----|------4-----|------------|2--2--2--2--|
	  |------------|------------|------------|------------|
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	[B](Verse Refrain)
	   F#m          B            E            C#m
	  |------------|------------|------------|------------| 
	  |4--2--1-----|------------|------------|------------|
	  |---------4--|2--0--------|------2-----|4--4-----4--|
	  |------------|------4--2--|0--4-----4--|------4-----|
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	   A            B            E           (3x to Bridge)
	  |------------|------------|------------|------------:||
	  |---------2--|------4-----|2-----------|------------:||
	  |0--0--4-----|2--2-----2--|---4--2-----|------------:||
	  |------------|------------|---------4--|0-----------:||
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	[C]Bridge
	   C#m          C#maj7/C(B#) E
	  |------------|------------|------------|------------|
	  |------------|------------|2--2--------|2--2-----2--|
	  |4--4--------|3--3-----3--|------2--2--|------2-----|
	  |------4--4--|------4-----|------------|------------|
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	   C#m          C#maj7/C(B#)  E            (2x to Coda)
	  |------------|------------|------------|------------||
	  |------------|------------|2-(2)-------(2--2)---(2)-||
	  |4--4--------|3--3-----3--|---4--2-(2)-|-----(2)----||
	  |------4--4--|------4-----|---------4--|0-----------||
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	ALL MY LOVING (BASS GUITAR) Page 2

	[D]Guitar Break
	   A                         E
	  |------------|2-----------|------------|------------|
	  |------2--4--|---4--2-----|2-----------|------------|
	  |0--4--------|---------4--|---4--2-----|------2--4--|
	  |------------|------------|---------4--|0--4--------|
	 1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	 F#m          B7           E            (Back to Verse)
	  |------------|------------|------------|------------||
	  |4--2--1-----|------------|2-----------|------------||
	  |---------4--|2--0--------|---4--2-----|------------||
	  |------------|------4--2--|---------4--|0-----------||
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	[E]Coda
	   C#m                       E
	  |------------|------------|------------|------------|
	  |------------|------------|2--2--------|2--2-----2--|
	  |4--4--------|4--4-----4--|------2--2--|------2-----|
	  |------4--4--|------4-----|------------|------------|
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4

	   C#m                       E
	  |------------|------------|------------|------------||
	  |------------|------------|2--2--------|------------||
	  |4--4--------|4--4--------|------2--2--|------------||
	  |------4--4--|------4--4--|------------|0-----------||
	   1  2  3  4   1  2  3  4   1  2  3  4   1  2  3  4
	
Top

Web Design for Beginners: Real World Coding in HTML & CSS

Section: 1

Welcome!

1. Course Introduction

Section: 2

HTML Essentials

2. Why HTML is Exciting
3. First Look at HTML
4. The Easiest Way to Get Started
5. Hands On! Create your First HTML File
6. Russian Stacking Dolls: Bulleted Lists
7. HTML Document Structure

Section: 3

Adding Media to a Web Page

10. Images
11. Audio Files
12. Video Files

Section: 4

Text Basics

13. Text Basics
14. Lists
15. Bold & Italic
16. Special Characters

Section: 5

Semantics & Organization

17. Semantic Structura Elements
18. Navigation
19. Non-semantic Elements ("div" and "span")
20. HTML Comments
21. The "Section" Element

Section: 6

Forms

22. Forms
23. Different Types of Inputs
24. Choosing Between a set of Options

Section: 7

Tables

25. How to Create a Table of Data
26. Do Not Use Tables for Layout

Section: 8

CSS Essentials

27. CSS Introduction
28. CSS Selectors
29. The Cascade
30. Box Model
31. Creating a Page Layout with Floats
32. Beauty School! Apply What We've Learned

Section: 9

Intermediate CSS

33. Styling Navigation Menu
  • (0:16) Creating a Navigation Menu with an Unordered List - nesting <a href> within <li> tags
  • (1:19) Removing bullets with li {list-style: none;} & CSS /* Comments */
  • (2:08) Placing links side by side with li {float: left;}
  • (3:40) Styling 'links' with the a anchor tag
  • (4:55) Problem: content above/below not recognising padding/margin of button-style links
  • (5:20) Solution: convert anchor from 'inline' to 'block' level
  • (6:53) Creating hover effect on mouse-over with a:hover pseudo selector
34. Overlapping Content & Transparent Backgrounds

Section: 10

Less Exciting Yet Still Necessary CSS Tasks

35. Styling Data Tables
36. Styling Forms

Section: 11

CSS Typography

2. CSS Typography
3. Using Custom "Web" Fonts

Section: 12

Developer Timeout!

39. Developer Tools | Inspect Elements

Section: 13

CSS Backgrounds

40. Background Images
41. Gradient Backgrounds
42. CSS Sprites
43. Full Width Backgrounds - Fixed Width Content

Section: 14

Responsive Web Design

44. Responsive Web Design
45. Responsive Grids

Section: 15

CSS3 Special Effects

46. Why HTML is Exciting
47. First Look at HTML
48. The Easiest Way to Get Started
49. Hands On! Create your First HTML File
50. Russian Stacking Dolls: Bulleted Lists

Section: 16

Leveraging JavaScript without Writing JavaScript

51. Slideshow (Part 1)
52. Slideshow (Part 2)
53. Reveal & Hide Content on Click / Tap
54. Open Image in Modal Window (Gallery)

Section: 17

Sass

55. Sass Introduction
  • Intro
  • Sass Compilers
  • (04:18bm=bookmarked) Getting started: screen.scss ("sassy" css)
  • (06:30bm) Variables: coloring links with Sass - $primaryColor: #ec7705
  • (09:05bm)Nesting: styling the navigation menu with Sass - nesting in the CSS selectors -- clear floats
  • (12:50bm)Inheritance/@extend
Sass (CSS Extension Language • Sass Compilers: (online) SassMeister or CodePen; (installed) Koala or Scout • screen.scss ("sassy"ss) • Sass features:
  • Variables
  • Nesting
  • Inheritance
  • Splitting into Smaller Files / @import
  • ...and, next tutorial:
  • Mixins
  • Operators
; • Sass feature for adjusting color: 'lighten'
56. Sass Continued

Section: 18

Cross Browser Compatibility

57. Feature Detection
58. Browser & Device Testing

Section: 19

Beyond This Course

59. Next Steps
Top

Table of 'List' Properties and Values

Property: Value; Inh.
list-style
Examples
list-style-image url(url) | none
Examples
list-style-position inside | outside
Examples
list-style-type disc | circle | square | decimal | decimal-leading-zero | upper-alpha | lower-alpha | upper-roman | lower-roman | lower-greek | none
Examples

Tutorial: Styling the 'Lists' Element—version 1.

Below is the HTML markup for a simple Unordered List. Copy and paste the markup text into a text editor and view it in a browser window.

   <ul>
     <li>Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

The browser's own default style sheet will render it like this:

Using CSS, we can override the browser's default style sheet and begin creating our own. For example, I think it looks a little odd for the Title to be styled with a bullet, along with the List Items, as if it were an actual List Item. It's not. It's a title. And I'd like it to look a little more like how a proper title should look, and that's what we'll be doing in this tutorial.

So let's begin by removing this inappropriate Title bullet. We can do that easily with the list-style-type property. One of its values, none, allows us to turn off bullets. (It also allows us to choose different kinds of bullets, or even add our own custom image to use as a bullet, if we want.) But for now, we just want to remove the bullet.

Add the following 'in line' code into the markup you copied earlier:

   	<ul>
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   	</ul>
	

When you've done that, Save, and then Refresh the browser window. Here's how it should now look:

Top

Good! The bullet's now gone. But perhaps you'll agree, it might look even better if 'Title' didn't appear to share the same indented look as the other 'List Items'? We can "un-indent" the Title with the following CSS property, list-style-position and giving it a value of inside. I'll expain what's happening in a moment. For now, keep the previous code, and just type in the following. When you're done, Save and Refresh.

   <ul style="list-style-position: inside;">
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

In the browser it should now look like this:

That looks much better, doesn't it? We could almost leave it at that. But we'll go on to add even more styling shortly.

First of all, let's go back a moment. Previously, I suggested we "un-indent" the Title; but if we look carefully at the list now, and compare it with the previous one, we'll notice the Title hasn't shifted at all. It's in exactly the same position now as it was before. What has shifted is the position of the List Items and bullets. They've moved further to the right. Fascists, or what?

Actually, the Title and List Items were in their own little text block, with the bullets sitting outside that block—just like hanging indents. When we gave the list-style-position the value of inside we really replaced the browser's default value of outside.

(If you'd like to test it out, go back and replace the inside value with outside. Try it a few times—don't forget to Save and Refresh each time. When you're done, return the value to inside.)

Let's move on and add a bit more styling. I think it would look better if the whole block sat flush against the left page margin. We can achieve this by removing all the default margin-left or padding-left properties the browser adds on. Type in the following:

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

In the browser, it should now look like this, flush against the left margin:

Again, we could leave it just as it is. But we often want our Titles to really stand out and catch the eye. A simple, and effective way to do that is to make it bold. We could do that by simply styling it 'bold'. But Titles are important — and 'bold' merely catches the eye. Let's use, instead, the semantically rich <strong>...</strong> HTML element instead. This adds semantic weight to the title (which Search Engines pick up on). Now we just need to wrap 'Title' in it:

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;"><strong>Title</strong></li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

And in the browser...

Now the 'Title' value is much easier to identify. And wouldn't it be just that little bit classier if we added some color?

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;"><strong style="color: teal;">Title</strong></li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

Let's take a last peek:

It looks good. And so that brings this tutorial to an end.

Top

Tutorial: Styling the 'List' Element—version 2

In this tutorial we'll learn how to override the browser's default style sheet and turn a simple Unordered List from this:

...into this:

First, copy and paste the following markup into a text editor and then view it in a browser window:

   <ul>
     <li>Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

It will look exactly like the first example shown above. That's the browser's default style sheet at work. We need to override it by adding a style sheet of our own. Let's begin. Type the following CSS code into the markup text you've just copied, taking care to place it within the Title's opening tag, and including the two spaces:

   <ul>
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

It should now look like this in the browser (if it doesn't, check your typing!):

Notice the bullet has been removed from the Title. This is much more in keeping with its role as a Title, not a List item.

Now we'll take the List item bullets—which by default are placed outside the text block—and place them inside. Enter the following new code (in bold) into the markup:

   <ul style="list-style-position: inside;">
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

In the browser it should now look like this:

Notice the bullets are now sitting directly beneath the Title. It looks a lot better. But the list is still indented. In our finished example, above, we had it flush against the left margin of the page. To achieve this, type the following into the markup:

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;">Title</li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

And in the browser...

...we can see it is now flush against the left margin. Good! We could, of course, leave things exactly as they are now—but let's go a little further and make the Title really stand out. We can do this by placing it within the HTML <strong>...</strong> element. Let's now add it to the markup:

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;"><strong>Title</strong></li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

And in the browser:

Excellent! Now let's finally style the Title with a color in keeping with the document's other titles:

   <ul style="list-style-position: inside; margin-left: 0; padding-left: 0;">
     <li style="list-style-type: none;"><strong style="color: teal;">Title</strong></li>
     <li>List item</li>
     <li>List item</li>
   </ul>
	

Let's take a last peek:

It looks good. And so that brings this tutorial to an end.

Top

In this tutorial we are going to turn this,

  • List item
  • List item
  • List item

...into this,

  • List item
  • List item
  • List item

Step one, adding a background color to ul

  • List item
  • List item
  • List item

Step two, limiting the width

  • List item
  • List item
  • List item

Step 3, adding a background color to li

  • List item
  • List item
  • List item

Step 4, bringing the bullet inside

  • List item
  • List item
  • List item

The four steps given above very clearly give a demonstration of how width, default padding, and bullets inside and outside work.

Block Level Styling—The Unordered List

Block level elements—such as <h1>, <p> and <ul>—can be styled directly and don't need to be wrapped in a <div>...</div> to achieve this. If the element being styled is unique to that page—for instance, the site's navigation menu—consider simply just using an id attribute within the element's opening tag, <ul id="unique-nav">, rather than wrapping it in a <div>. This makes for smaller download files. If, however, the element being styled is intended for repeated use, place a class attribute within its tag: e.g. <ul class="generic-nav">.

Although the styling methods used in this tutorial are applied to an Unordered List, the same, or similar, methods can be applied to any other block level element. Actually, to reinforce that last point, the Unordered List is itself a combination of two elements. The first is the parent element, the 'unordered list', or <ul>...</ul> The second element, wrapped within the parent element, is the 'list item', or <li>...</li>. It looks like this:

	  	      ----<ul>
	     parent   |	  <li></li>----   child
	    (wrapper) |	  <li></li>   | (wrapped)
	  	      |	  <li></li>----
	  	      ----</ul>
		

Back to our Unordered List and its code.

	  <ul>
	    <li>List item</li>
	    <li>List item</li>
	    <li>List item</li>
	  </ul>
		

The first thing we'll do is give it a background color.

Applying a Background Color to the List

To add a green background to the list we need to create a CSS rule. The simplest CSS rule consists of a property and a value, which are then placed within the HTML document using the style attribute. The syntax bonding them into a CSS rule is important. First we need to embed the style In our case, the property we require is background-color which is given the value of green. Using the inline style attribute, we place these in the opening <ul> tag of the list like this:

	  <ul style="background-color: green;">
	    <li>List item</li>
	    <li>List item</li>
	    <li>List item</li>
	  </ul>
		
	  ul {
	    background-color: green;
	  }
		
	  ul {background-color: green;}
		

Now that we've given the list a background color we can see how block level elements work - they take up the entire available horizontal space. We don't often realise this - but now we do, and recognise it's not what we want, let's constrain it - but before we do, I want to explore something rather interesting.

Tutorial: Constraining the Box

	  <ul style="width: 200px; background-color: green;">
	    <li>List item</li>
	    <li>List item</li>
	    <li>List item</li>
	  </ul>
		
	  ul {
	    width: 200px;
	    background-color: green;
	  }
		
	  ul {width: 200px; background-color: green;}
		
	  <ul style="background-color: green;">
	    <li style="background-color: lime;">List item</li>
	    <li style="background-color: lime;">List item</li>
	    <li style="background-color: lime;">List item</li>
	  </ul>
		

Applying Width Constraint

The inline style syntax given here:

	  <ul style="width: 200px; background-color: green;">
	    <li style="background-color: lime;">List item</li>
	    <li style="background-color: lime;">List item</li>
	    <li style="background-color: lime;">List item</li>
	  </ul>
		

...And the embedded and stylesheet syntax as shown here:

	  ul {
	    width: 200px;
	    background-color: green;
	  }

	  li {
	    background-color: lime;
	    }
		

Here's something might be worth noting: the presentation of rules in a CSS stylesheet, like the presentation above, is entirely a matter of choice. The fact is, CSS ignores all spaces and line breaks. So the rules above could have been presented on single lines, as shown below. That's how they'll be presented here for the rest of the tutorial.

	  ul {width: 200px; background-color: green;}
	  li {background-color: lime;}
		

An Interesting Design Possibility?

Background Colors, Paddings, Borders & Margins

 <ul style="width: 200px; padding: 40px; background-color: green; border: 5px solid purple;">
 <li style="background-color: teal">TEAL</li>
 <li style="margin-top: 10px; margin-bottom: 30px; background-color: lime">LIME</li>
 <li style="background-color: olive">OLIVE</li>
 </ul>
	
Floating 'List items' without using a Div

Without styling:


Back to that simple list,
	<ul>
		<li>List item</li>
		<li>List item</li>
		<li>List item</li>
	</ul>
	

And now with, "li {float: left;}" styling:

  <ul>
    <li style="float: left;">List item</li>
    <li style="float: left;">List item</li>
    <li style="float: left;">List item</li>
  </ul>
	

And now with, "ul {list-style-position: inside;}" styling:

  <ul style="list-style-position: inside;">
    <li style="float: left;">List item</li>
    <li style="float: left;">List item</li>
    <li style="float: left;">List item</li>
  </ul>
	

And now with, "li {margin-right: 40px; float: left;}" styling:

  <ul style="list-style-position: inside;">
    <li style="margin-right: 40px; float: left;">List item</li>
    <li style="margin-right: 40px; float: left;">List item</li>
    <li style="margin-right: 40px; float: left;">List item</li>
  </ul>
	

Top

Thoughts on Topic Structure

Novice

Note: The three books I'm reading, and Brad's Udemy course, take us through all of the above (and most of the next section, 'Basic') before introducing CSS. I think this may be a mistake. My opinion is turning to the idea that some very basic CSS styling options ought to be included, right now, and right here.

Basic

Intermediate

Advanced

Opening a PDF of Sunny Afternoon Bass Part for Sunny Afternoon

Top

Backgrounds

Property Value Examples
background Shorthand for, and in this suggested order: background-color, background-image, background-repeat, background-attachment and background-position • background: #333 url(images/logo.gif) no-repeat fixed left top;
background-attachment scroll (default) | fixed

Specifies whether background image scrolls with content, or remains fixed on screen.
• background-attachment: fixed;
background-clip border-box | padding-box | content-box (default) • background-clip: content-box;
• background-clip: padding-box;
background-color Any valid color value • background-color: rgba(122, 122, 122, .5);
background-image url(url)
Browser generated linear- or radial-gradient (Missing, pg. 252)
Multiply background images (Missing, pg. 249)
• background-image: url(images/logo1.gif);
• background-image: url(http://musictutors.net/images/logo.gif), url(images/logo2.gif);
background-origin border-box | padding-box | content-box (default)

Specifies the initial placement of the repeating or non-repeating background image.
background-position left | center | right || top | center | bottom

Percent and number (+ and - values allowed)

• Keywords: match any horizontal keyword (left of double line) to vertical keyword (to the right of double line). "left top", "right bottom", or "center center".
• Values given in space-separated pairs (horizontal, then vertical).
• Any value mixed with any other.
background-repeat repeat | no-repeat | repeat-x | repeat-y
background-size contain | cover

Positioning background-image with Percentage Values.

If you've ever tried percentage values to place an image with the background-position property, you may have been left somewhat perplexed. I certainly was. However, once you understand how it works, you'll probably think—as I did—"Ha! That's really rather clever." Here's how it works.

When you give a percentage value for the x and y coordinates—let's say both coordinates are given the value of 50%—the browser calculates where these coordinates meet within the containing box. At the same time (and this is the clever bit) it also calculates where these same coordinates meet within the imported image box. The browser then matches the two meeting points together, and that's where the image is placed within the container.

Let's see that in action. In the figure below, the larger box (representing the container box) begins, top left, at 0%, The x and y coordinates are then divided at 25%, 50%, 75%. At 100% they meet at the bottom right corner of the box.

In our example, above, we gave the x and y coordinates as 50% 50%. That gives us a point within the containing box right at the center. The browser also applied those coordinates to the imported image box (our yellow box, below) which was its center. The two points located, the browser matches them together at the center of both.

Background: box1

	  <div id="background-box1" style="width: 100%; height: 500px; border: 2px solid red; box-sizing: border-box;
		
background-image: url(images/background.jpg);"></div>
Top

Background: box2

	  <div id="background-box2" style="width: 100%; height: 500px; border: 2px solid red; box-sizing: border-box;
		
background-image: url(images/background2.jpg);"></div>
Top

Background: box3

	  <div id="background-box3" style="width: 100%; height: 500px; border: 2px solid red; box-sizing: border-box;
	  
background-image: url(images/background2.jpg); background-repeat: no-repeat;"></div>
Top

Background: box4

<div id="background-box4" style="width: 100%; height: 500px; border: 2px solid red; box-sizing: border-box;
	 background-image:
	 
url(images/background2.jpg); background-repeat: repeat-x;"></div>
Top

Background: box5

	<div id="background-box5" style="width: 100%; height: 500px; border: 2px solid red; box-sizing: border-box; 
		
background-image: url(images/background2.jpg); background-repeat: repeat-y;"></div>
Top

Background: box6

Shakespeare

If music be the food of love, play on;
Give me excess of it...

	<div id="background-box6" style="width: 100%; height: 500px; border: 2px solid red;  box-sizing: border-box; 
		
background-image: url(images/background3.jpg); background-repeat: repeat-y; background-position: right bottom; background-color: #c6a8aa"></div>

Small Boxes

Clear floats

Incididunt ut Labore et Dolore

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Incididunt ut Labore et Dolore

Incididunt ut Labore et Dolore Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Incididunt ut Labore et Dolore>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Top

The Background Image and Other Background Properties

Property Value
background-image: url(url);

url(url>),
url(url);
linear-gradient(keywords, values);
repeating-linear-gradient(keywords, values);

radial-gradient(keywords, values);
repeating-radial-gradient(keywords, values);
Top

The box below represents any area of a web page, however large (it could be the entire screen) or small, into which we wish to add the adjacent star graphic as a background image.

But first of all, just so we can see more clearly what happens next, let's add a simple grid to our web page area.

Background images are placed using the CSS declaration: background-image: url(url);. By default, the browser will first place the image in the top left corner—in our grid, the top left box—of the web page area; then the browser will duplicate (or tile) the image horizontally and vertically, until the entire available space is filled.

In our example, with the grid boxes and star graphic equally sized, this will result in the following neat arrangement of page area and image size,

But suppose the page area had been a little larger, or smaller. What would happen then? The browser would still tile the image across and down, starting from the top-left corner, until it had filled all the available space. However, when it reached the right and bottom border, if there were not sufficient space to render the complete image, the browser would simply, and brutally, have crop it, as can be seen below.

As we'll see, there are numerous ways to over-ride this default, using cousins of the background-image property.

The background-repeat property has four well-supported keyword values: repeat, no-repeat, repeat-x, and repeat-y; and two, as yet, poorly-supported values: round, and space. Here's an At-a-Glance:

Property Value
background-repeat: repeat; (default)
no-repeat;
repeat-x;
repeat-y;
round;
space;
Top
style="background-image: url(star.png); background-repeat: repeat;">
style="background-image: url(star.png); background-repeat: no-repeat;">
style="background-image: url(star.png); background-repeat: repeat-x;">
style="background-image: url(star.png); background-repeat: repeat-y;">
style="background-image: url(star.png); background-repeat: round;">
style="background-image: url(star.png); background-repeat: space;">
Top
Property x-Value y-Value
background-position: left



center



right
top; (default)
center;
bottom;

top;
center;
bottom;

top;
center;
bottom;
Note: If only one value is entered, the browser will treat it as the 'x' (horizontal) coordinate; by default, the value of the missing 'y' (vertical) coordinate will be 'center'.
Top

The background-attachment Property

Property Value
background-attachment: scroll; (default)
fixed;

The scroll/fixed Values

The scroll/fixed Values 1

Scroll away!


Top of the Box

Top of next Box

The scroll/fixed Values 2

Logo Banner

Please click the following link to position the box correctly in the browser window.

Then slowly scroll down and examine what happens as the background image emerges from beneath the banner.

You're right. It is magic!


Top of the Box

Top

The scroll/fixed Values 3

Logo Banner

Please click the following link to position the box correctly in the browser window.

Then slowly scroll down and examine what happens as the background image emerges from beneath the banner.

You're right. It is magic!

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Top of the Box

Top Dog

Making Background Images Clickable

Title

Box

Making Background Images Clickable2

Indentable Link

Making Background Images Clickable3

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Back to Background-Origin

Property Value
background-origin:
and
background-clip:
border-box; (default)
padding-box;
content-box;
Top Dog

The border-box Value

CONTENT

The padding-box Value

CONTENT

The content-box Value

CONTENT

CONTENT
goes here

CONTENT
goes here

CONTENT
goes here

Meow
Bottom|Page

This is a Header <h1> Element

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Links

Root Relative Links

The following photo, groupphoto.png,



lives in the 'images' directory, which is inside the root directory—along with index.html—right at the very top of the musictutors.net website.

This present document, however, lives in the 'html_css_reference' directory, which in turn lives in the 'hidden' directory which, in its turn, lives in the root directory, along side the 'images' and index.html. Although not impossibly fiendish, working out the url is still a challange to the old grey matter. But let's go through it.

From the present 'html-css-reference' directory, we move back up one step to the 'hidden' directory (that's one '../'). From there we go back to the root directory (that's another '../'). We're in a position to step down into the 'images' folder and retrieve the 'groupphoto.png' and place it here, in this document. Here's the url:

<img src="../../images/groupphoto.png" alt="">

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.