A reminder of HTML elements. Contribute to gendx/html-cheat-sheet development by creating an account on GitHub.
This cheat sheet - or HTML code quick reference - lists the common HTML tags and their attributes, grouped into relevant sections in an easy-to-read format.
What is html
? What are tags
? - Perhaps check out where to start or what is html first :-)
Basic HTML Structure | Help | Top |
---|
Common Tags for Blogs | Help | Top |
---|---|
<h?> heading </h?> | Heading (h1 for largest to h6 for smallest) |
<p> paragraph </p> | Paragraph of Text |
<b> bold </b> | Make text between tags bold |
<i> italic </i> | Make text between tags italic |
<a href='url'> link name </a> | Create a link to another page or website |
<div> ... </div> | Divide up page content into sections, and applying styles |
<img src='filename.jpg'> | Show an image |
<ul> <li> list </li> </ul> | Unordered, bullet-point list |
<br> | Line Break (force a new line) |
<span> red </span> | Use CSS style to change text colour |
Text Formatting | Help | Top |
---|---|
<h?> ... </h?> | Heading (?= 1 for largest to 6 for smallest, eg h1) |
<b> ... </b> | Bold Text |
<i> ... </i> | Italic Text |
<u> ... </u> | Underline Text |
<strike> ... </strike> | Strikeout |
<sup> ... </sup> | Superscript - Smaller text placed below normal text |
<sub> ... </sub> | Subscript - Smaller text placed below normal text |
<small> ... </small> | Small - Fineprint size text |
<tt> ... </tt> | Typewriter Text |
<pre> ... </pre> | Pre-formatted Text |
<blockquote> ... </blockquote> | Text Block Quote |
<strong> ... </strong> | Strong - Shown as Bold in most browsers |
<em> ... </em> | Emphasis - Shown as Italics in most browsers |
<font> ... </font> | Font tag obsolete, use CSS. (*) |
Section Divisions | Help | Top |
---|---|
<div> ... </div> | Division or Section of Page Content |
<span> ... </span> | Section of text within other content |
<p> ... </p> | Paragraph of Text |
<br> | Line Break |
<hr> | Basic Horizontal Line |
<hr> Tag Attributes: | |
size='?' | Line Thickness in pixels |
width='?' | Line Width in pixels |
width='??%' | Line Width as a percentage |
color='#??????' | Line Colour(*) |
align='?' | Horizontal Alignment: left, center, right (*) |
noshade | No 3D cut-out |
<nobr> ... </nobr> | Line Break |
Images | Help | Top |
---|---|
<img src='url' alt='text'> | Basic Image |
<img> Tag Attributes: | |
src='url' | URL or filename of image (required!) |
alt='text' | Alternate Text (required!) |
align='?' | Image alignment within surrounding text (*) |
width='??' | Image width (in pixels or %) |
height='??' | Image height (in pixels or %) |
border='??' | Border thickness (in pixels) (*) |
vspace='??' | Space above and below image (in pixels) (*) |
hspace='??' | Space on either side of image (in pixels) (*) |
Linking Tags | Help | Top |
---|---|
<a href='url'> link text </a> | Basic Link |
<a> Tag Attributes: | |
href='url' | Location (url) of page to link to. |
name='??' | Name of link (name of anchor, or name of bookmark) |
target='?' | Link target location: _self, _blank, _top, _parent . |
href='url#bookmark' | Link to a bookmark (defined with name attribute). |
href='mailto:email' | Link which initiates an email (dependant on user's email client). |
Lists | Help | Top |
---|---|
<ol> ... </ol> | Ordered List |
<ul> ... </ul> | Un-ordered List |
<li> ... </li> | List Item (within ordered or unordered) |
<ol type='?'> | Ordered list type: A, a, I, i, 1 |
<ol start='??'> | Ordered list starting value |
<ul type='?'> | Unordered list bullet type: disc, circle, square |
<li value='??'> | List Item Value (changes current and subsequent items) |
<li type='??'> | List Item Type (changes only current item) |
<dl> ... </dl> | Definition List |
<dt> ... </dt> | Term or phrase being defined |
<dd> ... </dd> | Detailed Definition of term |
Tables | Help | Top |
---|---|
<table> ... </table> | Define a Table |
<table> Tag Attributes: | |
border='?' | Thickness of outside border |
bordercolor='#??????' | Border Colour |
cellspacing='?' | Space between cells (pixels) |
cellpadding='?' | Space between cell wall and content |
align='??' | Horizontal Alignment: left, center, right (*) |
bgcolor='#??????' | Background Colour (*) |
width='??' | Table Width (pixels or %) (*) |
height='??' | Table Height (pixels or %) (*) |
<tr> ... </tr> | Table Row within table |
<th> ... </th> | Header Cell within table row |
<td> ... </td> | Table Cell within table row |
<td> Tag Attributes: | |
colspan='?' | Number of columns the cell spans across (cell merge) |
rowspan='?' | Number of row a cell spans across (cell merge) |
width='??' | Cell Width (pixels or %) (*) |
height='??' | Cell Height (pixels or %) (*) |
bgcolor='#??????' | Background Colour (*) |
align='??' | Horizontal Alignment: left, center, right (*) |
valign='??' | Vertical Alignment: top, middle, bottom (*) |
nowrap | Force no line breaks in a particular cell |
Frames | Help | Top |
---|---|
<frameset> ... </frameset> | Define the set of Frames |
<frameset> Tag Attributes: | |
rows='??,??, ...' | Define row sizes & number of rows (size in pixels or %) |
cols='??,??, ...' | Define column sizes & number of columns (size in pixels or %) |
noresize='noresize' | User cannot resize any frames in frameset |
<frame> ... </frame> | Define a frame within the frameset |
<frame> Tag Attributes: | |
src='url' | Location of HTML File for a frame |
name='***' | Unique name of frame window |
marginwidth='?' | Horizontal margin spacing inside frame (pixels) |
marginheight='?' | Vertical margin spacing inside frame (pixels) |
noresize='noresize' | Declare all frameset sizes as fixed |
scrolling='***' | Can the user scroll inside the frame: yes, no, auto |
frameborder='?' | Frame Border: (1 =yes, 2 =no) |
bordercolor='#??????' | Border Colour (*) |
<noframes> ... </noframes> | Unframed content (for browsers not supporting frames) |
Forms | Help | Top |
---|---|
<form> ... </form> | Form input group decleration |
<form> Tag Attributes: | |
action='url' | URL of Form Script |
method='***' | Method of Form: get, post |
enctype='***' | For File Upload: enctype='multipart/form-data' |
<input> ... </input> | Input field within form |
<input> Tag Attributes: | |
type='***' | Input Field Type: text, password, checkbox, submit etc. |
name='***' | Form Field Name (for form processing script) |
value='***' | Value of Input Field |
size='***' | Field Size |
maxlength='?' | Maximum Length of Input Field Data |
checked | Mark selected field in radio button group or checkbox |
<select> ... </select> | Select options from drop down list |
<select> Tag Attributes: | |
name='***' | Drop Down Combo-Box Name (for form processing script) |
size='?' | Number of selectable options |
multiple | Allow multiple selections |
<option> ... </option> | Option (item) within drop down list |
<option> Tag Attributes: | |
value='***' | Option Value |
selected | Set option as default selected option |
<textarea> ... </textarea> | Large area for text input |
<textarea> Tag Attributes: | |
name='***' | Text Area Name (for form processing script) |
rows='?' | Number of rows of text shown |
cols='?' | Number of columns (characters per rows) |
wrap='***' | Word Wrapping: off, hard, soft |
Special Characters | Help | Top |
---|---|
< | < - Less-Than Symbol |
> | > - Greater-Than Symbol |
& | & - Ampersand, or 'and' sign |
" | ' - Quotation Mark |
© | © - Copyright Symbol |
™ | ™ - Trademark Symbol |
| - A space (non-breaking space) |
&#??; | ISO 8859-1 character - replace ?? with the iso code |
Miscellaneous Tags | Help | Top |
---|---|
<!-- ... --> | Comment within HTML source code |
<!DOCTYPE html ... > | Document Type Definition (wiki) |
<meta> ... </meta> | META information tag |
<meta> Tag Attributes: | |
name='***' | Meta name: description, keywords, author |
http-equiv='***' | HTTP Equivalent Info: title, etc. |
content='***' | Information content |
<link> | LINK content relationship tag |
<link> Tag Attributes: | |
rel='***' | Type of forward relationship |
http='url' | Location (URL) of object or file being linked |
type='***' | Type of object or file, eg: text/css |
title='***' | Link title (optional) |
Body Background & Colours | Help | Top |
---|---|
<body> Tag Attributes: | |
background='url' | Background Image (*) |
bgcolor='#??????' | Background Colour(*) |
text='#??????' | Document Text Colour (*) |
link='#??????' | Link Colour (*) |
vlink='#??????' | Visited Link Colour (*) |
alink='#??????' | Active Link Colour (*) |
bgproperties='fixed' | Background Properties - 'Fixed' = non-scrolling watermark (*) |
leftmargin='?' | Side Margin Size in Pixels (Internet Explorer) (*) |
topmargin='?' | Top Margin Size in Pixels (Internet Explorer) (*) |
Tags marked with (*) should still work, but have been superseded by Cascading Style Sheets (CSS), which is now the recommended way to change the font, colour, spacing, border or alignment of HTML elements.
This cheatsheet glances over some of the common syntax of F# 3.0. If you have any comments, corrections, or suggested additions, please open an issue or send a pull request to https://github.com/dungpa/fsharp-cheatsheet.
Block comments are placed between (*
and *)
. Line comments start from //
and continue until the end of the line.
XML doc comments come after ///
allowing us to use XML tags to generate documentation.
F# string
type is an alias for System.String
type.
Use verbatim strings preceded by @
symbol to avoid escaping control characters (except escaping '
by '
).
We don't even have to escape '
with triple-quoted strings.
Backslash strings indent string contents by stripping leading spaces.
Most numeric types have associated suffixes, e.g., uy
for unsigned 8-bit integers and L
for signed 64-bit integer.
Other common examples are F
or f
for 32-bit floating-point numbers, M
or m
for decimals, and I
for big integers.
See Literals (MSDN) for complete reference.
The let
keyword also defines named functions.
Pipe operator |>
is used to chain functions and arguments together. Double-backtick identifiers are handy to improve readability especially in unit testing:
This operator is essential in assisting the F# type checker by providing type information before use:
Composition operator >>
is used to compose functions:
The rec
keyword is used together with the let
keyword to define a recursive function:
Mutually recursive functions (those functions which call each other) are indicated by and
keyword:
Pattern matching is often facilitated through match
keyword.
In order to match sophisticated inputs, one can use when
to create filters or guards on patterns:
Pattern matching can be done directly on arguments:
or implicitly via function
keyword:
For more complete reference visit Pattern Matching (MSDN).
A list is an immutable collection of elements of the same type.
Arrays are fixed-size, zero-based, mutable collections of consecutive data elements.
A sequence is a logical series of elements of the same type. Individual sequence elements are computed only as required, so a sequence can provide better performance than a list in situations in which not all the elements are used.
The same list [ 1; 3; 5; 7; 9 ]
or array [| 1; 3; 5; 7; 9 |]
can be generated in various ways.
Using range operator ..
Using list or array comprehensions
Using init
function
Lists and arrays have comprehensive sets of higher-order functions for manipulation.
fold
starts from the left of the list (or array) and foldBack
goes in the opposite direction
reduce
doesn't require an initial accumulator
map
transforms every element of the list (or array)
iter
ate through a list and produce side effects
All these operations are also available for sequences. The added benefits of sequences are laziness and uniform treatment of all collections implementing IEnumerable<'T>
.
A tuple is a grouping of unnamed but ordered values, possibly of different types:
The first and second elements of a tuple can be obtained using fst
, snd
, or pattern matching:
Records represent simple aggregates of named values, optionally with members:
Records can be augmented with properties and methods:
Records are essentially sealed classes with extra topping: default immutability, structural equality, and pattern matching support.
Discriminated unions (DU) provide support for values that can be one of a number of named cases, each possibly with different values and types.
F# Core has a few built-in discriminated unions for error handling, e.g., Option and Choice.
Single-case discriminated unions are often used to create type-safe abstractions with pattern matching support:
The failwith
function throws an exception of type Exception
.
Exception handling is done via try/with
expressions.
The try/finally
expression enables you to execute clean-up code even if a block of code throws an exception. Here's an example which also defines custom exceptions.
This example is a basic class with (1) local let bindings, (2) properties, (3) methods, and (4) static members.
Call a base class from a derived one.
Upcasting is denoted by :>
operator.
Dynamic downcasting (:?>
) might throw an InvalidCastException
if the cast doesn't succeed at runtime.
Declare IVector
interface and implement it in Vector'
.
Another way of implementing interfaces is to use object expressions.
Complete active patterns:
Parameterized active patterns:
Partial active patterns share the syntax of parameterized patterns but their active recognizers accept only one argument.
Load another F# source file into FSI.
Reference a .NET assembly (/
symbol is recommended for Mono compatibility).
Include a directory in assembly search paths.
Other important directives are conditional execution in FSI (INTERACTIVE
) and querying current directory (__SOURCE_DIRECTORY__
).