HTML Cheat Sheet
This is a HTML cheat sheet for the most commonly used tags and
attributes.
Most tags have an opening and closing tag.
Basic Tags |
| <html></html>
Defines the html document |
| <head></head>
This defines the information about the html document such as the title |
| <body></body>
This is the main content of the document |
Header Tags |
| <title></title>
This is the title of the document and goes between the <head> |
Body Attributes |
| <body bgcolor=?> Sets the background color. Use the name or hex value of the |
| <body text=?>
Sets the text color. Use the name or hex value of the color. |
| <body link=?>
Sets the color of links. Use the name or hex value of the color. |
| <body vlink=?>
Sets the color of followed links. Use the name or hex value of the |
| <body alink=?>
Sets the color of links on click. Use the name or hex value of the |
Text Tags |
| <pre></pre>
Preformatted text |
| <h1></h1>
The largest headline |
| <h6></h6>
The smallest headline |
| <b></b>
Bold Text |
| <i></i>
Italic text |
| <tt></tt>
Teletype or typewriter-style text |
| <cite></cite>
Citation which is usually italic |
| <em></em>
Emphasizes a word |
| <strong></strong>
Emphasizes a word |
| <font size=?></font> Sets font size, from 1 to 7 |
| <font color=?></font> Sets font color. Use the name or hex value of the color. |
Links |
| <a href=”URL”></a> Defines a hyperlink |
| <a href=”mailto:EMAIL”></a> Defines a mailto link |
| <a name=”NAME”></a> Defines a target location within a document |
| <a href=”#NAME”></a> Links to that target location on the same page. Also referred to |
HTML Cheat Sheet for Formatting |
Formatting |
| <p>
Defines a new paragraph |
| <p align=?>
Aligns a paragraph to the left, right, or center |
| <br>
Inserts a line break <br /> (xhtml |
| <blockquote></blockquote>
Indents text from both sides |
| <dl></dl>
Defines a definition list |
| <dt>
Precedes each definition term |
| <dd>
Precedes each definition |
| <ol></ol>
Defines a numbered list |
| <li>
Precedes each list item and adds a number |
| <ul></ul>
Defines a bulleted list |
| <li>
Precedes each list item and adds the bullet |
| <div align=?>
A generic tag used to format large blocks of HTML; also used for |
HTML Cheat Sheet for Images |
Image and Graphical Elements |
| <img src=”name”> Adds an image |
| <img src=”name” align=?> Aligns an image: left, right, center, bottom, top, middle |
| <img src=”name” border=?> Sets size of border around an image |
| <hr>
Inserts a horizontal rule |
| <hr size=?>
Sets size (height) of rule |
| <hr width=?>
Sets width of rule in percentage or absolute value |
| <hr noshade>
Defines a rule without a shadow |
HTML Cheat Sheet for Tables and Table Attributes |
Tables |
| <table></table>
Defines a table |
| <tr></tr>
Sets off each row in a table |
| <td></td>
Sets off each cell in a row |
| <th></th>
Sets off the table header (a normal cell with bold, centered text) |
Table Attributes |
| <table border=#> Sets width of border around table cells |
| <table cellspacing=#> Sets amount of space between table cells |
| <table cellpadding=#> Sets amount of space between a cell’s border and its contents |
| <table width=# or %> Sets width of table in pixels or as a percentage of document width |
| <tr align=?> or <td align=?> Sets alignment for cell(s) (left, center, or right) |
| <tr valign=?> or <td valign=?> Sets vertical alignment for cell(s) (top, middle, or bottom) |
| <td colspan=#>
Sets number of columns a cell should span (default=1) |
| <td rowspan=#>
Sets number of rows a cell should span (default=1) |
| <td nowrap>
Prevents the lines within a cell from being broken to fit |
HTML Cheat Sheet for Frames and Frame Attributes |
Frames |
| <frameset></frameset>
Precedes the <body> tag in a frames document; can also be nested |
| <frameset rows=”value,value”> Defines the rows within a frameset, using number in pixels or |
| <frameset cols=”value,value”> Defines the columns within a frameset, using number in pixels or |
| <frame>
Defines a single frame within a frameset |
| <noframes></noframes>
Defines what will appear on browsers that don’t support frames |
Frames Attributes |
| <frame src=”URL”> Specifies which HTML document should be displayed |
| <frame name=”name”> Names the frame so it may be targeted by other frames |
| <frame marginwidth=#> Defines the left and right margins for the frame; must be equal to or |
| <frame marginheight=#> Defines the top and bottom margins for the frame; must be equal to or |
| <frame scrolling=VALUE> Sets whether the frame has a scroll bar; value may equal “yes,” “no,” |
| <frame noresize> Prevents the user from resizing a frame |
HTML Cheat Sheet for Forms |
Forms |
| For functional forms, you’ll have to run a CGI script. The HTML just Defines the appearance of a form. |
| <form></form>
Defines all forms |
| <select multiple name=”NAME” size=?></select> Defines a scrolling menu. Size sets the number of menu items visible |
| <option>
Sets off each menu item |
| <select name=”NAME”></select> Defines a pulldown menu |
| <option>
Sets off each menu item |
| <textarea name=”NAME” cols=40 rows=8></textarea> Defines a text box area – columns set the width; rows set the height. |
| <input type=”checkbox” name=”NAME”> Defines a checkbox – text follows tag. |
| <input type=”radio” name=”NAME” value=”x”> Defines a radio button – text follows tag |
| <input type=text name=”foo” size=20> Defines a one-line text area – size sets length in characters. |
| <input type=”submit” value=”NAME”> Defines a Submit button |
| <input type=”image” border=0 name=”NAME” src=”name.gif”> Defines a Submit button using an image |
| <input type=”reset”> Defines a Reset button |
