CSS, JavaScript and XHTML Explained

Estelle Weyl’s Blog of quirks, random thoughts and funky finds discovered in day-to-day coding

 

CSS Selectors and Browser Support April 29, 2007

Filed under: CSS (including hacks), IE7, Web Development — Estelle Weyl @ 12:42 am

Note: This grid is OUTDATED! Please see Grid of CSS3 Selectors and Browser Support


Below are the various CSS selectors, including CSS3 selectors, and current browser support. Green / √ means current support. Orange / Δ means that the browsers have some support for the selector. Red / Χ means that the browser is non-compliant. Non-compliant selectors can be used and a valid way to target individual browsers.

  iPhn Windows XP Mac OSX
Selector Saf 3.0 FF 2.0 FF 1.5 Op
9.0
Saf
3.0
IE7 IE6 Saf 1.3 Op FF 2 NS 7.1
*
E
.class 1.
#id
E F
E > F Χ
E + F Χ
E[attr] Δ Χ Δ
E[attr=val] Δ Δ Δ Δ Δ Χ Δ Δ Δ Δ
E[attr~=val] Δ Δ Δ Δ Δ Χ Δ Δ Δ
E[attr|=val] Δ Δ Δ Δ Δ Χ Δ Δ Δ
:first-child Δ Δ Δ Δ Δ Δ Χ Δ Δ Δ
:link Χ
:visited Χ
:lang() Δ Χ Χ Χ Δ
:before Χ Χ Χ
::before Χ Χ Χ
:after Χ Χ Χ
::after Χ Χ Χ
:first-letter Χ
::first-letter Χ Χ
:first-line Χ
::first-line Χ Χ
The following selectors are new to CSS3 (above were in previous versions)
E[attr^=val] Δ Δ Δ Χ Δ Χ Χ Δ Χ Δ Δ
E[attr$=val] Δ Δ Δ Χ Δ Χ Χ Δ Χ Δ Δ
E[attr*=val] Δ Δ Δ Δ Χ Χ Δ Δ Δ
E ~ F Χ Χ Χ
:root Χ Χ Χ Χ
:last-child Χ Δ Δ Χ Χ Χ Χ Χ Χ Δ Δ
:only-child Χ Δ Δ Χ Χ Χ Χ Χ Χ Δ Χ
:nth-child() Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:nth-last-child() Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:first-of-type Δ Χ Χ Χ Δ Χ Χ Χ Χ Χ Χ
:last-of-type Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:only-of-type Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:nth-of-type() Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:nth-last-of-type() Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ Χ
:empty Χ Δ Δ Χ Χ Χ Χ Χ Χ Δ Δ
:not() Χ Χ Χ Χ
:target Χ Χ Χ Χ
:enabled Χ Χ Χ Χ
:disabled Χ Χ Χ Χ
:checked Χ Χ Χ

Notes:

  • 1. IE6 doesn’t errs on mulitple classes.  A double class such as

    .red.green { }  .green { }  <p class="green red"></p>

    Both CSS selectors should match, but the dual declaration should take precendence as it is more specific. So the second should be able to define additional properties, but not overwrite properties from the first. IE6 fails here.

  • Check out the definition of Double Colon Notation
  • The Avant Browser selector support is identical to IE7. It was removed from the list to make the table narrower.
 
 

Javascript, CSS, and (X)HTML entities in numeric order April 28, 2007

Filed under: Character Entities, HTML, Web Development — Estelle Weyl @ 12:40 am


Named HTML entities in numeric order

Below are the entities listed in numeric order with definition and ISO numeric code. CSS 'content' does not accept named entities or regular numeric entities such as &#64;, but does render ASCII text and unicode.

If you want to replace the bullets in a bulleted list with a different character, perhaps a ♥ or · you would need to use the unicode entity rather than the named or numeric entity: use the hexadecimal entity.

li:before {content:"\2665"; text-indent: -10px;}

JavaScript Special Characters / Entities

If you want to include characters in JavaScript, the process is very similar to the CSS inclusion method, except : in JavaScript use octal-encoded characters without a preceding 0 instead of the HTML entity for the normal chars, and the hex character preceded by a \u for all other characters..

alert('M\351nage \340 trois.')

Notes:

  • If you know the numeric value of your HTML entity, use the handy CSS & Javascript Entity Calculator to get the JS and/or CSS code
  • There is a much smaller list of named entities in alphabetical order which may be a good place to start. Find the entity you are looking for there by appearance, then do a search for the numeric entity or named entity here.
  • Remember that IE doesn’t understand the :before pseudoclass with content, and you would have to set the list-style-type as none, or you would get 2 bullets in CSS compliant browsers.
  • In the above if you see two backslashes it’s because some browsers escape the backslashes and others don’t, so I stuck two in.
  • If you click on any javascript entities in the "alerts" javascript entity column below, the entity will show up as an alert.

Named entities, numeric entities and ISO numeric codes

Special characters for (X)HTML

&quot; &#34; " quotation mark, a.k.a. apl quote u+0022 ISOnum p:before { content:"\0022"; } alert("\42")
&amp; &#38; & ampersand u+0026 ISOnum p:before { content:"\0026"; } alert("\46")
&lt ; &#60; < less-than sign u+003C ISOnum p:before { content:"\003c"; } alert("\74");
&gt ; &#62; > greater-than sign u+003E ISOnum p:before { content:"\003e"; } alert("\76");

Latin-1 entity set for HTML

Name   Numeric Description Hex ISO in CSS content Octal
&nbsp;   &#160; no-break space %A0 p:before { content:"\00a0"; } alert("\240");
&iexcl; ¡ &#161; inverted exclamation mark %A1 p:before { content:"\00a1"; } alert("\241");
&cent; ¢ &#162; cent sign %A2 p:before { content:"\00a2"; } alert("\242");
&pound; £ &#163; pound sterling sign %A3 p:before { content:"\00a3"; } alert("\243");
&curren; ¤ &#164; general currency sign %A4 p:before { content:"\00a4"; } alert("\244");
&yen; ¥ &#165; yen sign %A5 p:before { content:"\00a5"; } alert("\245");
&brvbar; ¦ &#166; broken (vertical) bar %A6 p:before { content:"\00a6"; } alert("\246");
&sect; § &#167; section sign %A7 p:before { content:"\00a7"; } alert("\247");
&uml; ¨ &#168; umlaut (dieresis) %A8 p:before { content:"\00a8"; } alert("\250");
&copy; © &#169; copyright sign %A9 p:before { content:"\00a9"; } alert("\251");
&ordf; ª &#170; ordinal indicator, feminine %AA p:before { content:"\00aa"; } alert("\252");
&laquo; « &#171; angle quotation mark, left %AB p:before { content:"\00ab"; } alert("\253");
&not; ¬ &#172; not sign %AC p:before { content:"\00ac"; } alert("\254");
&shy; ­ &#173; soft hyphen %AD p:before { content:"\00ad"; } alert("\255");
&reg; ® &#174; registered sign %AE p:before { content:"\00ae"; } alert("\256");
&macr; ¯ &#175; macron %AF p:before { content:"\00af"; } alert("\257");
&deg; ° &#176; degree sign %B0 p:before { content:"\00b0"; } alert("\260");
&plusmn; ± &#177; plus-or-minus sign %B1 p:before { content:"\00b1"; } alert("\261");
&sup2; ² &#178; superscript two %B2 p:before { content:"\00b2"; } alert("\262");
&sup3; ³ &#179; superscript three %B3 p:before { content:"\00b3"; } alert("\263");
&acute; ´ &#180; acute accent %B4 p:before { content:"\00b4"; } alert("\264");
&micro; µ &#181; micro sign %B5 p:before { content:"\00b5"; } alert("\265");
&para; &#182; pilcrow (paragraph sign) %B6 p:before { content:"\00b6"; } alert("\266");
&middot; · &#183; middle dot %B7 p:before { content:"\00b7"; } alert("\267");
&cedil; ¸ &#184; cedilla %B8 p:before { content:"\00b8"; } alert("\270");
&sup1; ¹ &#185; superscript one %B9 p:before { content:"\00b9"; } alert("\271");
&ordm; º &#186; ordinal indicator, masculine %BA p:before { content:"\00ba"; } alert("\272");
&raquo; » &#187; angle quotation mark, right %BB p:before { content:"\00bb"; } alert("\273");
&frac14; ¼ &#188; fraction one-quarter %BC p:before { content:"\00bc"; } alert("\274");
&frac12; ½ &#189; fraction one-half %BD p:before { content:"\00bd"; } alert("\275");
&frac34; ¾ &#190; fraction three-quarters %BE p:before { content:"\00be"; } alert("\276");
&iquest; ¿ &#191; inverted question mark %BF p:before { content:"\00bf"; } alert("\277");
&Agrave; À &#192; capital A, grave accent %C0 p:before { content:"\00c0"; } alert("\300");
&Aacute; Á &#193; capital A, acute accent %C1 p:before { content:"\00c1"; } alert("\301");
&Acirc; Â &#194; capital A, circumflex accent %C2 p:before { content:"\00c2"; } alert("\302");
&Atilde; Ã &#195; capital A, tilde %C3 p:before { content:"\00c3"; } alert("\303");
&Auml; Ä &#196; capital A, dieresis or umlaut mark %C4 p:before { content:"\00c4"; } alert("\304");
&Aring; Å &#197; capital A, ring %C5 p:before { content:"\00c5"; } alert("\305");
&AElig; Æ &#198; capital AE diphthong (ligature) %C6 p:before { content:"\00c6"; } alert("\306");
&Ccedil; Ç &#199; capital C, cedilla %C7 p:before { content:"\00c7"; } alert("\307");
&Egrave; È &#200; capital E, grave accent %C8 p:before { content:"\00c8"; } alert("\310");
&Eacute; É &#201; capital E, acute accent %C9 p:before { content:"\00c9"; } alert("\311");
&Ecirc; Ê &#202; capital E, circumflex accent %CA p:before { content:"\00ca"; } alert("\312");
&Euml; Ë &#203; capital E, dieresis or umlaut mark %CB p:before { content:"\00cb"; } alert("\313");
&Igrave; Ì &#204; capital I, grave accent %CC p:before { content:"\00cc"; } alert("\314");
&Iacute; Í &#205; capital I, acute accent %CD p:before { content:"\00cd"; } alert("\315");
&Icirc; Î &#206; capital I, circumflex accent %CE p:before { content:"\00ce"; } alert("\316");
&Iuml; Ï &#207; capital I, dieresis or umlaut mark %CF p:before { content:"\00cf"; } alert("\317");
&ETH; Ð &#208; capital Eth, Icelandic %D0 p:before { content:"\00d0"; } alert("\320");
&Ntilde; Ñ &#209; capital N, tilde %D1 p:before { content:"\00d1"; } alert("\321");
&Ograve; Ò &#210; capital O, grave accent %D2 p:before { content:"\00d2"; } alert("\322");
&Oacute; Ó &#211; capital O, acute accent %D3 p:before { content:"\00d3"; } alert("\323");
&Ocirc; Ô &#212; capital O, circumflex accent %D4 p:before { content:"\00d4"; } alert("\324");
&Otilde; Õ &#213; capital O, tilde %D5 p:before { content:"\00d5"; } alert("\325");
&Ouml; Ö &#214; capital O, dieresis or umlaut mark %D6 p:before { content:"\00d6"; } alert("\326");
&times; × &#215; multiply sign %D7 p:before { content:"\00d7"; } alert("\327");
&Oslash; Ø &#216;

capital O, slash

%D8 p:before { content:"\00d8"; } alert("\330");
&Ugrave; Ù &#217; capital U, grave accent %D9 p:before { content:"\00d9"; } alert("\331");
&Uacute; Ú &#218; capital U, acute accent %DA p:before { content:"\00da"; } alert("\332");
&Ucirc; Û &#219; capital U, circumflex accent %DB p:before { content:"\00db"; } alert("\333");
&Uuml; Ü &#220; capital U, dieresis or umlaut mark %DC p:before { content:"\00dc"; } alert("\334");
&Yacute; Ý &#221; capital Y, acute accent %DD p:before { content:"\00dd"; } alert("\335");
&THORN; Þ &#222; capital THORN, Icelandic %DE p:before { content:"\00de"; } alert("\336");
&szlig; ß &#223; small sharp s, German (sz ligature) %DF p:before { content:"\00df"; } alert("\337");
&agrave; à &#224; small a, grave accent %E0 p:before { content:"\00e0"; } alert("\340");
&aacute; á &#225; small a, acute accent %E1 p:before { content:"\00e1"; } alert("\341");
&acirc; â &#226; small a, circumflex accent %E2 p:before { content:"\00e2"; } alert("\342");
&atilde; ã &#227; small a, tilde %E3 p:before { content:"\00e3"; } alert("\343");
&auml; ä &#228; small a, dieresis or umlaut mark %E4 p:before { content:"\00e4"; } alert("\344");
&aring; å &#229; small a, ring %E5 p:before { content:"\00e5"; } alert("\345");
&aelig; æ &#230; small ae diphthong (ligature) %E6 p:before { content:"\00e6"; } alert("\346");
&ccedil; ç &#231; small c, cedilla %E7 p:before { content:"\00e7"; } alert("\347");
&egrave; è &#232; small e, grave accent %E8 p:before { content:"\00e8"; } alert("\350");
&eacute; é &#233; small e, acute accent %E9 p:before { content:"\00e9"; } alert("\351");
&ecirc; ê &#234; small e, circumflex accent %EA p:before { content:"\00ea"; } alert("\352");
&euml; ë &#235; small e, dieresis or umlaut mark %EB p:before { content:"\00eb"; } alert("\353");
&igrave; ì &#236; small i, grave accent %EC p:before { content:"\00ec"; } alert("\354");
&iacute; í &#237; small i, acute accent %ED p:before { content:"\00ed"; } alert("\355");
&icirc; î &#238; small i, circumflex accent %EE p:before { content:"\00ee"; } alert("\356");
&iuml; ï &#239; small i, dieresis or umlaut mark %EF p:before { content:"\00ef"; } alert("\357");
&eth; ð &#240; small eth, Icelandic %F0 p:before { content:"\00f0"; } alert("\360");
&ntilde; ñ &#241; small n, tilde %F1 p:before { content:"\00f1"; } alert("\361");
&ograve; ò &#242; small o, grave accent %F2 p:before { content:"\00f2"; } alert("\362");
&oacute; ó &#243; small o, acute accent %F3 p:before { content:"\00f3"; } alert("\363");
&ocirc; ô &#244; small o, circumflex accent %F4 p:before { content:"\00f4"; } alert("\364");
&otilde; õ &#245; small o, tilde %F5 p:before { content:"\00f5"; } alert("\365");
&ouml; ö &#246; small o, dieresis or umlaut mark %F6 p:before { content:"\00f6"; } alert("\366");
&divide; ÷ &#247; divide sign %F7 p:before { content:"\00f7"; } alert("\367");
&oslash; ø &#248; small o, slash %F8 p:before { content:"\00f8"; } alert("\370");
&ugrave; ù &#249; small u, grave accent %F9 p:before { content:"\00f9"; } alert("\371");
&uacute; ú &#250; small u, acute accent %FA p:before { content:"\00fa"; } alert("\372");
&ucirc; û &#251; small u, circumflex accent %FB p:before { content:"\00fb"; } alert("\373");
&uuml; ü &#252; small u, dieresis or umlaut mark %FC p:before { content:"\00fc"; } alert("\374");
&yacute; ý &#253; small y, acute accent %FD p:before { content:"\00fd"; } alert("\375");
&thorn; þ &#254; small thorn, Icelandic %FE p:before { content:"\00fe"; } alert("\376");
&yuml; ÿ &#255; small y, dieresis or umlaut mark %FF p:before { content:"\00ff"; } alert("\377");

Latin Extended-A

&OElig; Œ &#338; latin capital ligature oe u+0152 ISOlat2 p:before { content:"\0152"; } alert("\u0152");
&oelig; œ &#339; latin small ligature oe
(ligature is a misnomer, this is a separate character in some languages)
u+0153 ISOlat2 p:before { content:"\0153"; } alert("\u0153");
&Scaron; Š &#352; latin capital letter s with caron u+0160 ISOlat2 p:before { content:"\0160"; } alert("\u0160");
&scaron; š &#353; latin small letter s with caron u+0161 ISOlat2 p:before { content:"\0161"; } alert("\u0161");
&Yuml; Ÿ &#376; latin capital letter y with diaeresis u+0178 ISOlat2 p:before { content:"\0178"; } alert("\u0178");

Mathematical, Greek and Symbolic characters for HTML (& spacing modifiers)

Latin Extended-B

&fnof; ƒ &#402; latin small f with hook, a.k.a. function, a.k.a. florin u+0192 ISOtech p:before { content:"\0192"; } alert("\u0192");

Spacing Modifier Letters

&circ; ˆ modifier letter circumflex accent u+02C6 ISOpub p:before { content:"\02c6"; } alert("\u02c6");
&tilde; ˜ small tilde u+02DC ISOdia p:before { content:"\02dc"; } alert("\u02dc");

Greek

&Alpha; Α &#913; greek capital letter alpha u+0391 p:before { content:"\0391"; } alert("\u0391");
&Beta; Β &#914; greek capital letter beta u+0392 p:before { content:"\0392"; } alert("\u0392");
&Gamma; Γ &#915; greek capital letter gamma u+0393 ISOgrk3 p:before { content:"\0393"; } alert("\u0395");
&Delta; Δ &#916; greek capital letter delta u+0394 ISOgrk3 p:before { content:"\0394"; } alert("\u0394");
&Epsilon; Ε &#917; greek capital letter epsilon u+0395 p:before { content:"\0395"; } alert("\u0395");
&Zeta; Ζ &#918; greek capital letter zeta u+0396 p:before { content:"\0396"; } alert("\u0396");
&Eta ; Η &#919; greek capital letter eta u+0397 p:before { content:"\0397"; } alert("\u0397");
&Theta; Θ &#920; greek capital letter theta u+0398 ISOgrk3 p:before { content:"\0398"; } alert("\u0398");
&Iota; Ι &#921; greek capital letter iota u+0399 p:before { content:"\0399"; } alert("\u0399");
&Kappa; Κ &#922; greek capital letter kappa u+039A p:before { content:"\039a"; } alert("\u039a");
&Lambda; Λ &#923; greek capital letter lambda u+039B ISOgrk3 p:before { content:"\039b"; } alert("\u039b");
&Mu ; Μ &#924; greek capital letter mu u+039C p:before { content:"\039c"; } alert("\u039c");
&Nu ; Ν &#925; greek capital letter nu u+039D p:before { content:"\039d"; } alert("\u039D");
&Xi ; Ξ &#926; greek capital letter xi u+039E ISOgrk3 p:before { content:"\039e"; } alert("\u039e");
&Omicron; Ο &#927; greek capital letter omicron u+039F p:before { content:"\039f"; } alert("\u039f");
&Pi ; Π &#928; greek capital letter pi u+03A0 ISOgrk3 p:before { content:"\03a0"; } alert("\u03a0");
&Rho ; Ρ &#929; greek capital letter rho u+03A1 p:before { content:"\03a1"; } alert("\u03a1");
there is no Sigmaf, and no u+03A2 character either)
&Sigma; Σ &#931; greek capital letter sigma u+03A3 ISOgrk3 p:before { content:"\03a3"; } alert("\u03A3");
&Tau ; Τ &#932; greek capital letter tau u+03A4 p:before { content:"\03a4"; } alert("\u03A4");
&Upsilon; Υ &#933; greek capital letter upsilon u+03A5 ISOgrk3 p:before { content:"\03a5"; } alert("\u03A5");
&Phi ; Φ &#934; greek capital letter phi u+03A6 ISOgrk3 p:before { content:"\03a6"; } alert("\u03A6");
&Chi ; Χ &#935; greek capital letter chi u+03A7 p:before { content:"\03a7"; } alert("\u03A7");
&Psi ; Ψ &#936; greek capital letter psi u+03A8 ISOgrk3 p:before { content:"\03a8"; } alert("\u03A8");
&Omega; Ω &#937; greek capital letter omega u+03A9 ISOgrk3 p:before { content:"\03a9"; } alert("\u03A9");
&alpha; α &#945; greek small letter alpha u+03B1 ISOgrk3 p:before { content:"\03b1"; } alert("\u03b1");
&beta; β &#946; greek small letter beta u+03B2 ISOgrk3 p:before { content:"\03b2"; } alert("\u03b2");
&gamma; γ &#947; greek small letter gamma u+03B3 ISOgrk3 p:before { content:"\03b3"; } alert("\u03b3");
&delta; δ &#948; greek small letter delta u+03B4 ISOgrk3 p:before { content:"\03b4"; } alert("\u03b4");
&epsilon; ε &#949; greek small letter epsilon u+03B5 ISOgrk3 p:before { content:"\03b5"; } alert("\u03b5");
&zeta; ζ &#950; greek small letter zeta u+03B6 ISOgrk3 p:before { content:"\03b6"; } alert("\u03b6");
&eta ; η &#951; greek small letter eta u+03B7 ISOgrk3 p:before { content:"\03b7"; } alert("\u03b7");
&theta; θ &#952; greek small letter theta u+03B8 ISOgrk3 p:before { content:"\03b8"; } alert("\u03b8");
&iota; ι &#953; greek small letter iota u+03B9 ISOgrk3 p:before { content:"\03b9"; } alert("\u03b9");
&kappa; κ &#954; greek small letter kappa u+03BA ISOgrk3 p:before { content:"\03ba"; } alert("\u03ba");
&lambda; λ &#955; greek small letter lambda u+03BB ISOgrk3 p:before { content:"\03bb"; } alert("\u03bb");
&mu ; μ &#956; greek small letter mu u+03BC ISOgrk3 p:before { content:"\03bc"; } alert("\u03bc");
&nu ; ν &#957; greek small letter nu u+03BD ISOgrk3 p:before { content:"\03bd"; } alert("\u03bd");
&xi ; ξ &#958; greek small letter xi u+03BE ISOgrk3 p:before { content:"\03be"; } alert("\u03be");
&omicron; ο &#959; greek small letter omicron u+03BF NEW p:before { content:"\03bf"; } alert("\u03bf");
&pi ; π &#960; greek small letter pi u+03C0 ISOgrk3 p:before { content:"\03c0"; } alert("\u03c0");
&rho ; ρ &#961; greek small letter rho u+03C1 ISOgrk3 p:before { content:"\03c1"; } alert("\u03c1");
&sigmaf; ς &#962; greek small letter final sigma u+03C2 ISOgrk3 p:before { content:"\03C2"; } alert("\u03c2");
&sigma; σ &#963; greek small letter sigma u+03C3 ISOgrk3 p:before { content:"\03C3"; } alert("\u03c3");
&tau ; τ &#964; greek small letter tau u+03C4 ISOgrk3 p:before { content:"\03C4"; } alert("\u03c4");
&upsilon; υ &#965; greek small letter upsilon u+03C5 ISOgrk3 p:before { content:"\03C5"; } alert("\u03c5");
&phi ; φ &#966; greek small letter phi u+03C6 ISOgrk3 p:before { content:"\03C6"; } alert("\03c6");
&chi ; χ &#967; greek small letter chi u+03C7 ISOgrk3 p:before { content:"\03C7"; } alert("\u03c7");
&psi ; ψ &#968; greek small letter psi u+03C8 ISOgrk3 p:before { content:"\03C8"; } alert("\u03c8");
&omega; ω &#969; greek small letter omega u+03C9 ISOgrk3 p:before { content:"\03C9"; } alert("\u03c9");
&thetasym; ϑ &#977; greek small letter theta symbol u+03D1 NEW p:before { content:"\03D1"; } alert("\u03D1");
&upsih; ϒ &#978; greek upsilon with hook symbol u+03D2 NEW p:before { content:"\03D2"; } alert("\u03D2");
&piv ; ϖ &#982; greek pi symbol u+03D6 ISOgrk3 p:before { content:"\03D6"; } alert("\u03D6");

General Punctuation

&ensp; &#8194; en space u+2002 ISOpub p:before { content:"\2002";} alert("\u2002");
&emsp; &#8195; em space u+2003 ISOpub p:before { content:"\2003";} alert("\u2003");
&thinsp; &#8201; thin space u+2009 ISOpub p:before { content:"\2009";} alert("\u2009");
&zwnj; &#8204; zero width non-joiner u+200C NEW RFC 2070 p:before { content:"\200C";} alert("\u200C");
&zwj; &#8205; zero width joiner u+200D NEW RFC 2070 p:before { content:"\200D";} alert("\u200d");
&lrm; &#8206; left-to-right mark u+200E NEW RFC 2070 p:before { content:"\200E";} alert("\u200e");
&rlm; &#8207; right-to-left mark u+200F NEW RFC 2070 p:before { content:"\200F";} alert("\u200f");
&ndash; &#8211; en dash u+2013 ISOpub p:before { content:"\2013";} alert("\u2013");
&mdash; &#8212; em dash u+2014 ISOpub p:before { content:"\2014";} alert("\u2014");
&lsquo; &#8216; left single quotation mark u+2018 ISOnum p:before { content:"\2018";} alert("\u2018");
&rsquo; &#8217; right single quotation mark u+2019 ISOnum p:before { content:"\2019";} alert("\u2019");
&sbquo; &#8218; single low-9 quotation mark u+201A NEW p:before { content:"\201A";} alert("\u201a");
&ldquo; &#8220; left double quotation mark u+201C ISOnum p:before { content:"\201C";} alert("\u201c");
&rdquo; &#8221; right double quotation mark u+201D ISOnum p:before { content:"\201D";} alert("\u201d");
&bdquo; &#8222; double low-9 quotation mark u+201E NEW p:before { content:"\201E";} alert("\u201e");
&dagger; &#8224; dagger u+2020 ISOpub p:before { content:"\2020";} alert("\u2020");
&Dagger; &#8225; double dagger u+2021 ISOpub p:before { content:"\2021";} alert("\u2021");
&permil; &#8240; per mille sign u+2030 ISOtech p:before { content:"\2030";} alert("\u2030");
&lsaquo; &#8249; single left-pointing angle quotation mark
(lsaquo is proposed but not yet ISO standardised)
u+2039 ISO proposed p:before { content:"\2039";} alert("\u2039");
&rsaquo; &#8250; single right-pointing angle quotation mark
rsaquo is proposed but not yet ISO standardised
u+203A ISO proposed p:before { content:"\203A";} alert("\u203a");

General Punctuation

&bull; &#8226; bullet, a.k.a. black small circle
bullet is NOT the same as bullet operator — u+2219
u+2022 ISOpub alert("\u2219");
&hellip; &#8230; horizontal ellipsis, a.k.a. three dot leader u+2026 ISOpub alert("\u2026");
&prime; &#8242; prime, a.k.a. minutes, a.k.a. feet u+2032 ISOtech alert("\u2032");
&Prime; &#8243; double prime, a.k.a. seconds, a.k.a. inches u+2033 ISOtech alert("\u2033");
&oline; &#8254; overline, a.k.a. spacing overscore u+203E NEW alert("\u203e");
&frasl; &#8260; fraction slash u+2044 NEW alert("\u8260");

Letterlike Symbols

&weierp; &#8472; script capital P, a.k.a. power set, a.k.a. Weierstrass p u+2118 ISOamso alert("\u2118");
&image; &#8465; blackletter capital I, a.k.a. imaginary part u+2111 ISOamso alert("\u2111");
&real; &#8476; blackletter capital R, a.k.a. real part symbol u+211C ISOamso alert("\u211c");
&trade; &#8482; trade mark sign u+2122 ISOnum alert("\u2122");
&alefsym; &#8501; alef symbol, a.k.a. first transfinite cardinal
alef symbol is NOT the same as hebrew letter alef — u+05D0 although the same glyph
could be used to depict both characters
u+2135 NEW alert("\u");

Arrows

&larr; &#8592; leftwards arrow u+2190 ISOnum alert("\u2190");
&uarr; &#8593; upwards arrow u+2191 ISOnum alert("\u2191");
&rarr; &#8594; rightwards arrow u+2192 ISOnum alert("\u2192");
&darr; &#8595; downwards arrow u+2193 ISOnum alert("\u2193");
&harr; &#8596; left right arrow u+2194 ISOamsa alert("\u2194");
&crarr; &#8629; downwards arrow with corner leftwards, a.k.a. carriage return u+21B5 NEW alert("\u21b5");
&lArr; &#8656; leftwards double arrow
can be used for ‘is implied by’
u+21D0 ISOtech alert("\u21d0");
&uArr; &#8657; upwards double arrow u+21D1 ISOamsa alert("\u21d1");
&rArr; &#8658; rightwards double arrow u+21D2 ISOtech alert("\u21d2");
&dArr; &#8659; downwards double arrow u+21D3 ISOamsa alert("\ud1d3");
&hArr; &#8660; left right double arrow u+21D4 ISOamsa alert("\u21d4");


Mathematical Operators

&forall; &#8704; for all u+2200 ISOtech alert("\u2200");
&part; &#8706; partial differential u+2202 ISOtech alert("\u2202");
&exist; &#8707; there exists u+2203 ISOtech alert("\u2203");
&empty; &#8709; empty set, a.k.a. null set, a.k.a. diameter u+2205 ISOamso alert("\u2205");
&nabla; &#8711; nabla, a.k.a. backward difference u+2207 ISOtech alert("\u2207");
&isin; &#8712; element of u+2208 ISOtech alert("\u2208");
&notin; &#8713; not an element of u+2209 ISOtech alert("\u2209");
&ni ; &#8715; contains as member u+220B ISOtech alert("\u220b");
&prod; &#8719; n-ary product, a.k.a. product sign
prod is NOT the same character as u+03A0 ‘greek capital letter pi’ though the same
glyph might be used for both
u+220F ISOamsb alert("\u03a0");
&sum ; &#8721; n-ary sumation
sum is NOT the same character as u+03A3 ‘greek capital letter sigma’ though the same
glyph might be used for both
u+2211 ISOamsb alert("\u03a3");
&minus; &#8722; minus sign u+2212 ISOtech alert("\u2212");
&lowast; &#8727; asterisk operator u+2217 ISOtech alert("\u2217");
&radic; &#8730; square root, a.k.a. radical sign u+221A ISOtech alert("\u221a");
&prop; &#8733; proportional to u+221D ISOtech alert("\u221d");
&infin; &#8734; infinity u+221E ISOtech alert("\u221e");
&ang ; &#8736; angle u+2220 ISOamso alert("\u2220");
&and ; &#8869; logical and, a.k.a. wedge u+2227 ISOtech alert("\u2227");
&or ; &#8870; logical or, a.k.a. vee u+2228 ISOtech alert("\u2228");
&cap ; &#8745; intersection, a.k.a. cap u+2229 ISOtech alert("\u2229");
&cup ; &#8746; union, a.k.a. cup u+222A ISOtech alert("\u222a");
&int ; &#8747; integral u+222B ISOtech alert("\u222b");
&there4; &#8756; therefore u+2234 ISOtech alert("\u2234");
&sim ; &#8764; tilde operator, a.k.a. varies with,
similar to tilde operator, but is NOT the same character as the tilde u+007E,
although the same glyph might be used to represent both
u+223C ISOtech alert("\u223c");
&cong; &#8773; approximately equal to u+2245 ISOtech alert("\u2245");
&asymp; &#8776; almost equal to, a.k.a. asymptotic to u+2248 ISOamsr alert("\u2248");
&ne ; &#8800; not equal to u+2260 ISOtech alert("\u2260");
&equiv; &#8801; identical to u+2261 ISOtech alert("\u2261");
&le ; &#8804; less-than or equal to u+2264 ISOtech alert("\u2264");
&ge ; &#8805; greater-than or equal to u+2265 ISOtech alert("\u2265");
&sub ; &#8834; subset of u+2282 ISOtech alert("\u2282");
&sup ; &#8835; superset of
note that nsup, ‘not a superset of u+2283′ is not covered by the Symbol font
encoding and is not included.
u+2283 ISOtech alert("\u2283");
&nsub; &#8836; not a subset of u+2284 ISOamsn alert("\u2284");
&sube; &#8838; subset of or equal to u+2286 ISOtech alert("\u2286");
&supe; &#8839; superset of or equal to u+2287 ISOtech alert("\u2287");
&oplus; &#8853; circled plus, a.k.a. direct sum u+2295 ISOamsb alert("\u2295");
&otimes; &#8855; circled times, a.k.a. vector product u+2297 ISOamsb alert("\u2297");
&perp; &#8869; up tack, a.k.a. orthogonal to, a.k.a. perpendicular u+22A5 ISOtech alert("\u22a5");
&sdot; &#8901; dot operator
dot operator is NOT the same character as u+00B7 middle dot
u+22C5 ISOamsb alert("\u22c5");

Miscellaneous Technical

&lceil; &#8968; left ceiling, a.k.a. apl upstile u+2308, ISOamsc alert("\u2308");
&rceil; &#8969; right ceiling u+2309, ISOamsc alert("\u2309");
&lfloor; &#8970; left floor, a.k.a. apl downstile u+230A, ISOamsc alert("\u230a");
&rfloor; &#8971; right floor u+230B, ISOamsc alert("\u230b");
&lang; &#9001; left-pointing angle bracket, a.k.a. bra
lang is NOT the same character as u+003C ‘less than’
or u+2039 ’single left-pointing angle quotation mark’
u+2329 ISOtech alert("\u2329");
&rang; &#9002; right-pointing angle bracket, a.k.a. ket
rang is NOT the same character as u+003E ‘greater than’
or u+203A ’single right-pointing angle quotation mark’
u+232A ISOtech alert("\u232a");

Geometric Shapes

&loz ; &#9674; lozenge u+25CA ISOpub alert("\u25ca");

Miscellaneous Symbols

&spades; &#9824; black spade suit u+2660 ISOpub alert("\u2660");
&clubs; &#9827; black club suit, a.k.a. shamrock u+2663 ISOpub alert("\u2663");
&hearts; &#9829; black heart suit, a.k.a. valentine u+2665 ISOpub alert("\u2665");
&diams; &#9830; black diamond suit u+2666 ISOpub alert("\u2666");
 
 

Named HTML Entities in Alphabetical Order April 27, 2007

Filed under: Character Entities, HTML, Web Development — Estelle Weyl @ 11:12 am
A
Á &Aacute;
 &Acirc;
´ &acute;
Æ &AElig;
À &Agrave;
&alefsym;
Α &Alpha;
& &amp;
&and;
&ang;
Å &Aring;
&asymp;
à &Atilde;
Ä &Auml;
B
&bdquo;
Β &Beta;
¦ &brvbar;
&bull;
C
&cap;
Ç &Ccedil;
¸ &cedil;
¢ &cent;
Χ &Chi;
ˆ &circ;
&clubs;
&cong;
© &copy;
&crarr;
&cup;
¤ &curren;
D
&dagger;
&darr;
° &deg;
Δ &Delta;
&diams;
÷ &divide;
E
É &Eacute;
Ê &Ecirc;
È &Egrave;
&empty;
&emsp;
&ensp;
Ε &Epsilon;
&equiv;
Η &Eta;
Ð &ETH;
Ë &Euml;
&euro;
&exist;
F
ƒ &fnof;
&forall;
½ &frac12;
¼ &frac14;
¾ &frac34;
&frasl;
G
Γ &Gamma;
&ge;
> &gt;
H
&harr;
&hearts;
&hellip;
I
Í &Iacute;
Î &Icirc;
¡ &iexcl;
Ì &Igrave;
&image;
&infin;
&int;
Ι &Iota;
¿ &iquest;
&isin;
Ï &Iuml;
K
Κ &Kappa;
L
Λ &Lambda;
&lang;
« &laquo;
&larr;
&lceil;
&ldquo;
&le;
&lfloor;
&lowast;
&loz;
&lrm;
&lsaquo;
&lsquo;
< &lt;
M
¯ &macr;
&mdash;
µ &micro;
· &middot;
&minus;
Μ &Mu;
N
&nabla;
  &nbsp;
&ndash;
&ne;
&ni;
¬ &not;
&notin;
&nsub;
Ñ &Ntilde;
Ν &Nu;
O
Ó &Oacute;
Ô &Ocirc;
Œ &OElig;
Ò &Ograve;
&oline;
Ω &Omega;
Ο &Omicron;
&oplus;
&or;
ª &ordf;
º &ordm;
Ø &Oslash;
Õ &Otilde;
&otimes;
Ö &Ouml;
P
&para;
&part;
&permil;
&perp;
Φ &Phi;
Π &Pi;
ϖ &piv;
± &plusmn;
£ &pound;
&prime;
&prod;
&prop;
Ψ &Psi;
Q
" &quot;
R
&radic;
&rang;
» &raquo;
&rarr;
&rceil;
&rdquo;
&real;
® &reg;
&rfloor;
Ρ &Rho;
&rlm;
&rsaquo;
&rsquo;
S
&sbquo;
Š &Scaron;
&sdot;
§ &sect;
­ &shy;
Σ &Sigma;
ς &sigmaf;
&sim;
&spades;
&sub;
&sube;
&sum;
&sup;
¹ &sup1;
² &sup2;
³ &sup3;
&supe;
ß &szlig;
T
Τ &Tau;
&there4;
Θ &Theta;
ϑ &thetasym;
&thinsp;
Þ &THORN;
˜ &tilde;
× &times;
&trade;
U
Ú &Uacute;
&uarr;
Û &Ucirc;
Ù &Ugrave;
¨ &uml;
ϒ &upsih;
Υ &Upsilon;
Ü &Uuml;
W
&weierp;
X
Ξ &Xi;
Y
Ý &Yacute;
¥ &yen;
ÿ &yuml;
Z
Ζ &Zeta;
&zwj;
&zwnj;


 
 

CSS Best Practices April 23, 2007

Filed under: Best Practices, CSS (including hacks), Web Development — Estelle Weyl @ 9:49 pm

Separate content from presentation in order to make your website accessible to all users and devices, increase the longevity of your website (you won’t have to touch you HTML to alter the page’s layout), and enable the creating of new pages without worrying about consistency of appearance or layout. (Note that i wrote this in 2004 and posted here in 2007, so some stuff may be archaic).

General CSS Rules

  • Build and test your CSS in Firefox (or Safari if you are working on a Mac).
  • Specify units for non-zero values, but not for zero values.
  • Don’t use quotation marks around paths/URLs when setting a background image or loading in an imported file
  • Try to avoid applying padding/borders and a fixed width to an element. Rather, apply padding to the parent element.
  • Minimize number of ID’s used
  • Minimize number of classes used
  • Don’t use anchors, instead use ID’s.
  • Sandbox your style declarations
  • Combine selectors.
  • Use good naming conventions
  • Control the browsers CSS: Start with a clean slate.
  • Declare relative font sizes instead of absolute.
  • Create classes for error handling named based on the error
  • Avoid !important.
  • Avoid in-line CSS
  • Code link pseudo-classes in this order: Link, Visited, Hover, Active.

Stylesheet Maintenance

  • Minimize and clean up your css
  • Organize your CSS file
  • There are pros and cons to using Multiple stylesheets

HTML Development

  • Separate Structure and Presentation
  • Use HTML structure
  • Encompass everything in an element.
  • Use HTML elements for their intented purpose:
  • Avoid excess code
  • Avoid meaningless markup
  • Case sensitivity

General CSS Rules

Build and test your CSS in Firefox or Safari if you are working on a Mac.

  • Do not look at it or test your code in other browsers, especially IE, until the code is complete, approved and validated. This way you will start with clean, standards-compliant code that you can alter for non-standards compliant browsers, rather hacking from buggy code to support good browsers
  • If developing in Safari, develop with embedded styles in the header, but launch with imported styles to eliminate potential caching issues.
  • @import or <link> the css. It is better to <link rel="stylesheet" type="text/css" ... > because using @import can delay the rendering of your page.
  • Use as few browser hacks as possible, and document them with comments. Try to use valid CSS filters instead of non-validating hacks

Specify units for non-zero values.

  • Zero is zero, so do don’t include a unit type. For all other cases, CSS requires you to specify units on all quantities such as fonts, margins and sizes. Example: margin: 0 4px 0 2em;

Don’t use quotation marks around paths/URLs when setting a background image or loading in an imported file

  • They are not required or necessary and they will freeze IE5 on the Mac.

Try to avoid applying padding/borders and a fixed width to an element. Rather, apply padding to the parent element.

  • Because of IE 6 (and lower) box-model issues, if you apply padding to the parent element instead of the child element, IE will render the same as standards compliant browsers.

Minimize use of ID’s:

  • By encompassing sections in a named outer div, you can generally stylize all the contained components without the use of classes.
  • Use IDs sparingly: IDs have to be unique on a page, so using them for structural elements means that you can only ever have one content block on a page. #mainnavigation li li a should suffice for a drop down menu link and can be overwritten with #mainnavigation li li li a if there are submenus.
  • With minimal use of ID’s one can still target almost any element on the page, while allowing ASP.net autogenerated code (which is “ID happy”) to have the freedom to put ID’s all over the page.
  • Combine your selectors and sandbox your declarations (see below)

Minimize use of classes

  • Only use classes on elements that have any chance of being repeated on a page and in different locations, if the element is going to exist in a predictable location cascade based on the parent div ID,

Don’t use anchors, instead use ID’s.

  • Less code with multi-purpose code. Instead of using <a name=”anchor”> give an id to the parent of where that anchor would fall. All ID’s need to be unique, but so do the named anchors, so you are actually saving code and avoiding the pitfall of the effects of a a:hover defined for actual links

Sandbox your style declarations

  • Limit the “reach” of style declarations by pre-pending the class name, such as #maincontent p{}.

Combine selectors.

  • Keeping your CSS light is important to minimize download times; as much as possible, group selectors and rely on inheritance.

Naming conventions:

  • Never use layout descriptives in class names. Rather, use functional names for your classes, avoid words that describe how they look or where they are located on the page. “mainnavigation” is better than “leftnavigation”. Use “.copyright” and “.pullquote” instead of “smallgrey” or “indentitalic”. Name classes/IDs based on function, not appearance. If you create a .smallblue class, and later get a request to change the text to large and red, the class stops making any form of sense. Instead use descriptive classes like
  • Always use intention revealing classnames: Its tempting to use short cryptic class names (.s, .lbl) but unless you keep a glossary up to date of your class names, you will forget what they do. You may also run into problems with older browsers that can occasionally confuse classnames that start the same (i.e. .err and .errors are sometimes confused)
  • Avoid using the same classname for different purposes. The cascade can be very powerful but sometimes there is a temptation to use the same generic classname in many places. If you don’t sandbox your Css well, you can run into troubles.
  • Always use the same classname for similar purposes: Becuase the cascade is so powerful, you should reuse a classname in different places when they represent the same concept.
  • Put your classname on the outer-most element. The child elements can be targeted with the parent elements classname or ID. Often you see things like:<div class="headertitle">...</div>
    <div class="headerdescription">...</div>
    <div class="headerlinks">...</div>

    It’s far better to write:

    <div id="header">
    <h3>...</h3>
    <p>...</p>
    <ul><li>...</li><ul>
    </div>

  • Although class and div names can include lowercase, uppercase, numbers and additional characters in class and div names, it is best to use all lower case letters and to for multiple word classes, separate the words with an underscore or use camel case. HTML attributes “id” and “class” are case sensitive!
  • Never use javascript method or property names as ID values.  JavaScript DOM bindings specifies that javascript can index by id. For example, using “length” as an ID value on an element will cause headaches when using myObjects.length.

Start with a clean slate.

  • Create default page with no rendering; include this code but change color and font-family if necessarybody, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, p, blockquote, th, td { font-family: Arial, Helvetica, sans-serif; color:#000000; font-size: x-small;}
    table{border-collapse: collapse; border-spacing:0;}
    fieldset, img{border:0;}
    address, caption, cite, code, dfn, em, strong, th, var{font-style: normal; font-weight:normal;}
    h1, h2, h3, h4, h5, h6 {font-size:100%;}
    q:before, q:after{content:'';}
  • If you select other fonts for display, you don’t need to declare default classes since the first declaration declares default classes for all necessary elements.

Declare relative font sizes instead of absolute.

  • Always declare font-sizes in percentages or ems for maximum usability, consistency, and accessibility. This will enable pages to grow organically when user chooses to make text larger or smaller. Ems are easier to control than pixels.

Create classes for error handling named based on the error:

  • Form error handling is a good place to use multiple classnames. As an example, if you have a form, fields are typically either required or optional and have an error or not. Use “error required”, “error optional, “error feedback” (for a total of 4 classes, instead of 6), etc. Don’t call the classes “rederror”, redbigerror, etc, because when coding new error messages it won’t be obvious to the programmers which class to use.

Avoid !important.

Avoid in-line CSS

  • Inline styles negates the power of CSS and should only be used for testing purposes, such as including style=”border: 1px solid #ff0000;” to identify box model quirks

Code link pseudo-classes in this order: Link, Visited, Hover, Active.

  • In your CSS, code the links in order of a:link, a:visited, a:hover and a:active. Some people remember this best by the mneumonic “LoVe HAte”. In the hover definition, include visited:hover to ensure your hover effect works on visited links.

Stylesheet Maintenance

Minimize and clean up your css

  • Use as little CSS as possible, remove styles and parts of styles not being used or that were experimented with in the design process.

Organize your CSS file

  • Introduce your stylesheets with comments and explanation of how the particular sheet fits in with other sheets and with the site.
  • Use a predictable format. Organize similar rules together and use comments before each section to help you keep track of things for future redesigns/updates.
  • Group your styles with short and precise labels via comments
  • Make sure to comment blocks of CSS appropriately, group like-selectors, and establish a consistent naming convention, white space formatting. Incase different developers are using different platforms to edit the CSS, it is best to use spaces instead of tabs for white spce. Also, it is helpful to have consistent property order, though this is one I don’t do.
  • Start with clearing all default values, as mentioned above: this will reduce redundancy. Follow this by global styles. Lastly include section specific styles. For example, declare default element values. Next create sections of code for each section of your document. Next come the content sections which I generally divide into #header, #navigation, #maincontent and #footer. Include all the layout for the various elements for each of these id’s that are site global within each section
  • After site-wide declarations grouped by section/ID, if there are different “page colors” or layout looks, include a section for each of the different looks. If a declaration is valid for all “looks”, include it in the declarations above. If a declaration is valid for a subset of looks only, first declare a section for the multiple subset looks. This should be followed by unique page sections.
  • Finally, declare “weird” effects that only effect a paragraph type, a link based on value, etc.

Multiple stylesheets

  • Multiple stylesheets are appropriate for large and complexly styled sites, however extra http calls should be minimized.
  • Make sure multiple style sheets are really worth while - a single long CSS file can at least be searched easily (”find all instances of h2″)
  • The base styles file contains CSS rules that can be applied on every page, more specific sheets based on section or page color schema.

HTML Development

Separate Structure and Presentation

  • The goal should be to only have one line of CSS on the entire page: the call to an external style sheet.
    The eventual goal should also be to have one line of JavaScript - the call to the external file, with no inline event handlers, but we haven’t covered that yet.
  • Use semantic HTML structure that have semantic meaning such as <strong> and <em>
    instead of <b> and <large>. To give emphasis to a title, or stylizing a p tag, use semantic mark up such as <h1> thru <h6>

Encompass everything in an element.

  • <div> and <span> have no intrinsic meaning. Encompass all text in appropriate elements: <h1><h6>, <p>, <cite>, etc.

Use HTML elements for their intented purpose:

  • Use <blockquote> for blockquotes. <li> for list items, <cite> for citations.
  • Use list items for lists of links. Remember, navigations are generally a list of links and it is appropriate to use lists.

Avoid excess code,

  • Instead of repeated <br /> and  <p></p> use margin and padding

Avoid meaningless markup

  • Instead of <b> and <i>, use <strong> and <em>

Case sensitivity

  • All HTML markup, JavaScript, and CSS should be lowercase. Event handlers should be written in all lower case: use onlick not onClick. (actually, they should be in your JS, not in XHTML, but if you’re going to use them, make sure they’re lowercase). Use <p>, not <P>. Attribute values should all be lower case as well, unless referring to a file name that includes other characters. File names and file extensions should also be lowercase (no rule on this, just easier to remember class names, file names, image names, etc. if you don’t have to worry about case.
  • If a header should be all-caps, code it in regular case as you would want to see it printed, and then transform the text to all uppercase with CSS text transformation.


 
 

Controlling cursors with CSS and creating .cur files April 21, 2007

Filed under: CSS (including hacks), Cursors & Icons, Web Development — Estelle Weyl @ 11:22 am



Creatings Cursors, a.k.a. .cur files

You can convert images such as .jpgs or .gifs into cursors. A static cursor is saved as a .cur file. An animated cursor is saved as a .ani file.

To create a .cur or .ani file, you need specialized imagery software that is freely available. Available software includes the free Just Cursors that is a bitmap style editor and Icon Forge which costs money, but has much greater capabilities.

Here are the steps:

  • Download and install the imagery software of your choice, listed above.
  • Convert your image to a .cur file if you want a static cursor. For animated cursors, convert your animated .gif file into a .ani file.
  • Upload your image to your server.
  • Write a CSS class to target the cursor (see below for instructions)

Including cursors with CSS

To include image cursors, you need to have the .cur file loaded onto a server on the Internet so that you can point to it:

<style type="text/css">
li { cursor:url(http://www.yourdomain.com/images/yourimage.cur); }
</style>

If you want to simply control the browser default cursor with CSS you don’t use the image path, but rather, the cursor name:

li { cursor: text; }
a {cursor: pointer;}

Controlling cursors with JavaScript

You can dynamically change your cursor using javascript:

object.style.cursor="text"

List of Browser Cursors

Hover over any of the definitions below to see how the cursor renders in your browser:

Value   Appearance and default browser defined usage
url(image.cur) heart cursor Image cursor you defined (if browser supports it)
default default cursor The default cursor: default value for disabled form elements and media="print" styles.
auto auto cursor The browser’s default cursor: input[type="hidden"]
crosshair crosshair cursor Like a big plus sign
pointer pointer cursor hand pointer: input[type="image"]
move move cursor cross with four arrows: Image Resizing
e-resize East Resize cursor left-right arrows: Image Resizing
ne-resize northeast resize cursor arrows pointing northeast & southwest: Image Resizing
nw-resize northwest resize cursor arrows pointing northwest: Image Resizing
n-resize north resize cursor arrows pointing up & down (points northeast in IE): Image Resizing
se-resize southeast resize cursor arrows pointing northwest & southeast (points northeast in IE): Image Resizing
sw-resize southwest resize cursor arrows pointing northeast & southwest:Image Resizing
s-resize south resize cursor arrows pointing up & down (points northeast in IE): Image Resizing
w-resize west resize cursor left-right arrows: Image Resizing
text text cursor Line up and down, indicating text: input, textarea, a:visited, a:hover
wait wait cursor Watch or hourglass
help help cursor Question mark or balloon: not a default browser value for XHTML, but often used in conjunction with elements having a title attribute.
progress difference in browsers, but shows waiting: not a default browser value for XHTML, but often used in conjunction with elements having a title attribute.

Note:

  • I recommend against using image cursors, especially animated .gif cursors, since they are annoying.
  • You can even convert a Flash movie into a cursor: first export the movie as an animated gif, then export your .gif to an .ani file.
  • If you are declaring an image cursor, remember to always define a generic cursor at the end of the list in case none of the url-defined cursors can be used. A list of cursors should be specified, followed by a standard cursor designation. Then, if the user’s browser cannot handle the image cursor, it will use the the other specified cursor. If that doesn’t work, it will use the default cursor defined by the browser.
    {cursor: url("firstcursor.cur"), url("secondcursor.cur"), pointer;}
  • Safari, IE and Firefox support cursors of type .CUR and .ANI. URL-specified cursors are not yet supported by Netscape and the alternate cursor does not load, so you’ll get the default.
  • .cur is for a regular cursor, .ani is for an animated cursor.
  • To see the cursors on your desktop on windows navigate to C:\WINDOWS\Cursors


 
 

DTD - The Document Type Declaration April 20, 2007

Filed under: DTD, Web Development — Estelle Weyl @ 1:09 am


HTML5
<!DOCTYPE html>

XHTML 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 for Frames
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

HTML 4 Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

HTML 4 Loose
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML 4 Frames
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">

  • A DTD is a Document Type Definition, also know as DOCTYPE. In a document served as text/html, the DOCTYPE informs the browswer how to interpret the content of the page. If the the doctype is not declared, the browser assumes you don’t know how to code, and goes into "quirks mode". If you know what you are doing and include a correct XHTML DOCTYPE, your page will be rendered in "standards mode".

  • All of the above declarations will inform the browser to render the browser in standards mode. When authoring document is HTML or XHTML, it is important to Add a Doctype declaration. The declaration must be exact — both in spelling and in case. And, the URL must be included. If not, you risk having your page rendered in quirks mode. A list of the DTD’s and how browsers handle them can be found at http://hsivonen.iki.fi/doctype/

  • There are other DTD’s, such as <!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"> for MathML and <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
    "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
    for mobile. A list of valid DTDs is maintained at http://www.w3.org/QA/2002/04/valid-dtd-list.html

  • The XML declaration for XHTML web pages of <?xml version="1.0"?> is optional. Older browsers such as IE5 for the Mac choke on this. And, if you include it, IE6 renders in quirks mode, but IE7 renders in standards. So, for now, omit it. But, if you do include it, it must be the very first line, before the DTD

Why is quirks mode bad? Ever code a page and have the font inside your data tables be huge? That’s because in quirks mode browsers render td’s based on the browser default, not on the declared body default size. The box model is rendered differently and images as block instead of inline.

Why are DTD’s good? In addition to everything above, a DTD enables you to have valid code. To test validity, a page is compare to the rules for that document type. If you don’t have rules, how do you compare it? The DTD tells the validator what rules to use.

What is the difference between strict and transitional? Transitional allows deprecated tags and attributes to pass validation. The strict doctype is strict: depreciated tags and attributes will fail to validate under a strict doctype and may well display incorrectly as well. See Comparing XHTML and HTML, Strict and Transitional and Deprecated Elements and Attributes.

What does PUBLIC mean? In the above DOCTYPEs, all of them include the term "PUBLIC". If you are creating your own DTD then put your DTD on your sever and include the term "SYSTEM" with the path to your DTD file. On the other hand, if you are using PUBLIC DTD’s, such as those listed above, and the public identifier which starts with -//.

Sample:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This page is a the best DTD to use </title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

 
 

IE7 only CSS hacks: Explained April 18, 2007

Filed under: CSS (including hacks), IE7, Web Development — Estelle Weyl @ 10:52 pm



Targeting Internet Explorer 7

There are at least 6 ways to target IE7 only.

To see all these Hacks in action, open up IE7 Only CSS Hacks: Examples in your browser. The text will appear purple in IE7 and black/shades of grey in all other browsers

The Star (*) Hack

html>body .myClass { *color: #ff0033; } where color could be any attribute

Method:

  • Make it readable by IE with an asterisk in-front of the attribute, but not readable by any other browser. Other browsers skip over the attribute since it is not a valid attribute spelling
  • Make it not readable by IE6 by include the html>body.
    IE6 does not understand the html>body
  • This is the simplest way, but makes your CSS will not validate.

The conditional IE comment

<!--[if IE 7]>
<link rel=”stylesheet” type=”text/css”
href=”someFileName.css”>
<![endif]–>

Method:

  • This causes an extra http request, but only for IE7 users.
  • This is foolproof, and allows for correcting IE7 quirks. Quirks that i’ve
    found so far include rendering font sizes with em’s weirdly and a 3px offset on page centering.

The LANG filter

<body lang="en"> . . . </body>
(In XHTML, body should have the language attribute to make this work )

(then, you declare the IE7 and old browser value)

#item {background: red;}
html>body {background: blue;} 

*:lang(en) #item{background: green;}

This is read by FF & Opera. remember pseudo classes hold no value in the
cascade, so either put “!important”, or declare this value second…. declare the value second since you shouldn’t use important!

#item:empty {background: green !important} 

This is read by Safari supposedly, but i have yet to test.

  • The original article on this can be found at http://www.ibloomstudios.com/article7. I added the html>body to make this an IE7 only hack. IE7 understands the html>body, but IE6 does not.
  • I am still testing this one, and haven’t looked on a mac. But the bonus is
    this validates, and telling the screen readers and search engines that your
    page is in English is always a good idea.
  • Since this validates, I consider this a “filter” rather than a “hack”

Triple X Hack

From Brothercake, this hack takes advantage of IE7 support for the substring matching attribute selector, which is an improvement over IE6, and it’s continued lack of lack of support for the negation pseudo-class. And, since Opera 9 doesn’t support the negation pseudo-class, there’s an added CSS3 media query to negate the style for Opera 9.

p.test { color:red; }
p[id$="test"] { color:green; }
p[id$="test"]:not([class="xxx"]) { color:red; }
@media all and (min-width:0px) { p[id$="test"] { color:red; } }

<p id="text" class="test">This paragraph needs to have both a class and id to be targeted by this filter.</p>

Note

  • In the brother cake explanation another hack is presented: the XMLNS hack:

    p[id$="test"] { color:green; }
    html[xmlns] p[id$="test"] { color:red; }

    That hack doesn’t work for me: IE7 undertands the substring matching attribute selector.

The Case Sensitive Attribute Hack

The quirk in IE7’s support of substring matching attribute selectors can be exploited.  IE7 employs some case-sensitivity to the value of an attribute whether or not the attribute type requires case sensitivity. While it makes sense to compare id values in a case senstive manner, attribute values for HTML are case insensitive. The XHTML specifications state that element and attribute names must be lower case, but it does not say anything about attribute values.  In this case, img[align~=LEFT] will match align="LEFT" but not match align="left" but img[align~=left] will match align="left" and align="LEFT".

Code:

p[align~=left]{color: #0000ff;}
p[align~=LEFT]{color: #ff0000;}

<p align=”left”>This will blue in IE7, red in Firefox and black in IE6</p>

This will blue in IE7, red in Firefox and black in IE6

Method:

  • Use attribute selectors including E[attribute], E[attribute~=value], and E[attribute|=value], where the value is not truly case sensitive (such as align, but not alt or id. IE7 incorrectly requires the attribute value to be case sensitive.

Rationale:

  • For an understanding of why this works, please see my entry IE7 CSS Selectors: How they fail. I discovered this hack while testing out all the selectors.
  • Tested with XHTML transitional, Strict and HTML 4.01 strict
  • XHTML specifications state that attribute names are case sensitive, but don’t specify that attribute values need to be, so this is indeed valide

Notes

  • For me it makes most sense to add the cased attribute to the body tag instead of the each element that needs the hack. For example,

    p.casesensitive {color: #000000;}
    body[align~=left] p.casesensitive {color: #cc33cc;}
    body[align~=LEFT] p.casesensitive {color: #666666;}

    <body align="left"> <p class="casesensitive">This will purple in IE7, grey in Firefox and black in IE6</p>

    the body attribute can be used for all child elements, so useless attributes don’t need to be added throughout the HTML document.

Aimsterloo Hack

The :first-child pseudo-element works in most cases in IE7 except when the first child is a comment. IE7 treats the comment as the first child, even though CSS specifications state that :first-child should apply to elements, and comments are not elements. Note that there is a space between the selector and the colon. 

div :first-child {font-weight: bold;} will not match the paragraph in:
<div class="happy">
<!–comment –>
<p>Hi</p>
</div>

The trick to making this hack useful site wide is to add a useless comment immediately following the opening <body> tag.

p.fchild {color: #000000;}
html>body p.fchild {
color: #cc33cc;}
body :first-child p.fchild {color: #666666;}

<body><!– useless comment –><div><p class="fchild">The div should be the first child of the body, but in IE it isn’t…

Notes

  • I can’t show some of the hacks on this page since I didn’t do the template.  However, they can all be seen in My IE7 Hack Page.

Notes:

  • To see all these Hacks in action, visit IE7 Only CSS Hacks: Examples. The text will appear purple in IE7 and black/shades of grey in all other browsers
  • To learn all about how IE7 fails to understand specific CSS Selectors, I posted details in my blog at IE7 Css Selectors: How they Fail
  • If you would like to target IE6 and less, IE7 and all others separately using the * hack, the code would be:


    p {
    color: #ff0000;
        works in all
    *color: #00ff00;     targets IE6 and IE7
    _color: #0000ff;     targets IE6, not read by IE7
    }

  • The conditional statement can be used to link to an external stylesheet (recommended, because it’s best to separate style from content) or the style can be added where the link element is located in the above example, if you are looking to reduce HTTP requests.

    <!--[if IE 7]>
    <style type=”text/css”>
    p {color: #ff0000;}
    </style>
    <![endif]–>

 
 

About

Filed under: Web Development — Estelle Weyl @ 10:48 pm

My name is Estelle Weyl. I am a consulting web developer and have a full time job as a Web Developer too. I just updated the reinstalled the blog (5/28/2008), so please be patient if you are a Mac user… there are lots of quirks in the new template I still need to iron out.

If you have any recommendations on topics for me to hit, please let me know via comments. I am currently working on entries regarding: favicons, microformats, image effects using CSS, eventlisteners/eventhandlers and cross browser AJAX using YUI and a php proxy. Let me know!

View blog authority

At some point I will tell you a little about myself. But, in the meantime, I will spend time sharing knowledge I gain as I continue to develop websites. Here are some sites I have developed:


A comment about comments

All relevant comments will be approved whether they slam my work or support it, as long as the poster legitimately identifies themselves. Differing opinions are o.k. The reason there is an approval process is because I have better things to do than weed out spam, and web developers have better things to do then weed thru useless comments. Below is an innappropriate (a.k.a funny, but don’t open at work or if easily offended) video that explains why comment approval processes are needed.