HTML, CSS, and JavaScript Code Hints - dummies

HTML, CSS, and JavaScript Code Hints

By Sue Jenkins, Richard Wagner

Part of Dreamweaver CS5 All-in-One For Dummies Cheat Sheet

As a Web designer, you use some bits of HTML, CSS, and JavaScript code frequently but not often enough to commit to memory. The following HTML code, CSS style, and JavaScript hints are handy when you are adding special elements such as null links, meta tags, and entities to your pages. Use these HTML, CSS, and JavaScript code hints in Code view, the Properties inspector, and your CSS style sheets.

HTML Code Hint Code Shortcut
Create a null link # or javascript:; or javascript:void(0) as in<a
<a href=”javascript:;”>link</a>
<a href=”javascript:void(0)”>link</a>
Create named anchor link Link to Target
<a href=”#anchorname”>link</a>
<a name=”anchorname”></a>
Create link to named anchor in another page <a href=”otherpage.html#anchorname”>link</a>
Insert line break <br />
Close window JavaScript <a href=”javascript:window.close();”>Close This
Revisit after x days meta tag <meta name=”revisit-after” content=”5 days” />
No cache meta tag <meta http-equiv=”pragma” content=”no-cache”>
Meta link to home page <link rel=”Index” href=”index.html” />
Meta link to sitemap page <link rel=”Site Map” href=”sitemap.html” />
Meta link to shortcut icon <link rel=”Shortcut Icon” href=”favicon.ico” />
Meta link to shortcut icon using GIF instead of ICO <link rel=”Shortcut Icon” type=”image/gif”
href=”favicon.gif” />
Link to external JS file <script src=”myjsfile.js”
Link to external CSS <link rel=”stylesheet” type=”text/css” href=”css/ie.css”
Import@ link to external CSS <style media=”all” type=”text/css”>
@import “css/all.css”;
CSS link for IE browsers less than IE 7 <!–[if lt IE 7]><link rel=”stylesheet”
type=”text/css” href=”ie.css”
Insert an image with ALT attribute <img src=”images/myfile.png” alt=”My File” />
Empty ALT attribute for image <img src=”images/myfile.png” alt=” />
Entity to add blank space &nbsp; or &#160;
Entity to add copyright &copy; or &#169;
Entity to add trademark &trade; or &#153;
Entity to add ampersand &amp; or &#38;
Add NoScript tags <noscript>…
Link targets _blank
Apply CSS custom style with SPAN tags <span class=”stylename”>…
Comment tags in HTML and JavaScript <!– Your comment here //→
Comment tags in CSS /* Your comment here */
Structure of a CSS tag redefine style tag {
    attribute: value;
Structure of a CSS ID style #ID {
    attribute: value;
Structure of a CSS custom style .stylename {
    attribute: value;
CSS for link styles a:link {
    attribute: value;
a:visited {
    attribute: value;
a:hover {
    attribute: value;
a:active {
    attribute: value;;