BBCode, or BBML, uses "tags" to define what formatting to apply to the text. Tags are special codes surrounded by square brackets ("[]"). "Tag pairs" are used to define what formatting gets applied to what text. In most cases there will be a "start tag" followed by the text to be formatting followed by the "end tag". End tags are the same codes as the start tags prefixed by a forward slash ("/"). Here's a sample of the format:
[Tag]Text to be formatted[/tag]
The following general rules apply to all conversions:
BBCode (like HTML) must be "nested" properly. This is best explained with an example. The first line is not valid BBCode and will not be converted while the second line (with properly nested tags) is properly formatted:
Bad: [b]This is [i]some[/b] very fine[/i] sample text.
Good: [b]This is [i]some[/i][/b] [i]very fine[/i] sample text.
BBCode tags can be nested in this fashion as deeply as you like. Also BBCode tags not case sensitive. In other words [B][/B] and [b][/b] are treated identically.
Many BBCode tags have both long, easy to remember versions and shorter, easier to type versions. You cannot mix alternate begin and end tags however. For example "[b]bold text[/bold]" is illegal; either "[b]bold text[/b]" or "[bold]bold text[/bold]" must be used.
The basic formatting tags are what you'll be using most often. They general change the way that text is displayed on screen (bold, italic, etc) or add special formatting rules (indents, monospaced fonts, etc).
The following simple formatting tags are available.
Style | This BBcode | Converts to |
Bold | [b][/b] or [bold][/bold] | <b>bold</b> |
Italic | [i][/i] or [italic][/italic] | <i>italic</i> |
Underlined | [u][/u] or [underline][/underline] | <u>underlined</u> |
Strikethough | [s][/s] or [strikethrough][/strikethrough] | <s> |
Superscript | [sup][/sup] or [superscript][/superscript] | <sup>superscript</sup> |
Subscript | [sub][/sub] or [subscript][/subscript] | <sub>subscript</sub> |
Text color and size can be changed with the following tags:
Style | This BBCode |
Color | [color=color][/color] This tag will set the color of any text within it. Color can be any named color (red, blue, yellow, etc) or a hexidecimal rgb value (for example "#ccffcc"). |
Size | [size=size][/size] This tag will set the size (font point size) of any text within it. Size must be a number between 8 and 25. |
There are also four special types of simple formatting available:
Style | This BBCode |
Quotation | [q][/q] or [quote][/quote] or [quote="author"][/quote] This tag offsets and indents any text within it as per the HTML <blockquote></blockquote> tag. |
Code | [code][/code] Used around blocks of programming code (such as HTML, CFML, JavaScript, etc). |
SQL | [sql][/sql] Used around blocks of SQL code, this tag will bold all words reserved in the SQL92 and SQL99 standards such as "SELECT" and "DROP". |
Preformated | [pre][/pre] or [preformatted][/preformatted] Text placed within this tag will be displayed in a monospaced font and all spaces will be honored as per the HTML <pre></pre> tag. |
All simple formatting tags can be used within links, lists, and each other (as long as proper nesting rules are honored). This means that you can have very complex nestings and combinations of formatting. Here are some examples of simple formatting:
BBCode | Result |
This is [b]bold[/b] and this is [i]italic[/i]. | This is bold and this is italic. |
This [b]is a [i][sub]little[/sub] [u]more[/u][/i] complicated[/b] | This is a little more complicated |
This [i][s]is[/s] [u]even more complicated[/u][/i], [sup]but still perfectly [b]legal[/b][/sup]. | This |
This [color=blue]blue[/color] and this is [color=#FF0000]Red[/color]. | This blue and this is Red. |
[size=15]This text[/size] is larger than [size=8]this text[/size] but not as large as [size=25]this text[/size]. | This text is larger than this text but not as large as this text. |
There are two kinds of links available in BBCode: "normal" links and email links. A normal link is most often used to reference a web page or FTP site but any valid URL (a web address such as "http://www.depressedpress.com") can be used. An email link is specifically and only used for email address.
Their are two ways create a normal link, simple and complex:
Simple: [link]URL[/link] (or [url]URL[/url])
Complex: [link=URL]Link Label[/link] (or [url=URL]Link Label[/url])
In the same way there are two ways create an email link:
Simple: [email]address[/email]
Complex: [email=address]Label[/email]
In both cases the text between the tags is the visible, clickable part of the link.
Adding images is done with the [img][/img] (or, alternately, with the equivalent [image][/image] tag). You must wrap the full address of the image (for example "http://www.mysite.com/image.jpg") in the tag like so:
[img]image[/img]
The image tag can be wrapped in the [link] and [email] tags to make clickable images. However the [img] can not have any tags within it. In addition the [link] and [email] tags cannot wrap each other (although they may wrap basic formatting tags).
Here are some examples of links and images:
BBCode | Result |
[link]http://www.yahoo.com[/link] | http://www.yahoo.com |
[url=http://www.yahoo.com]Yahoo![/url] | Yahoo! |
[b][url=http://www.yahoo.com]Yahoo![/url][/b] | Yahoo! |
[email]bill.gates@microsoft.com[/email] | bill.gates@microsoft.com |
[email=ppan@neverland.com]Peter Pan[/email] | Peter Pan |
[img]http://www.depressedpress.com/Assets/Art/TopArrow.gif[/img] | ![]() |
[link=http://www.depressedpress.com][img]http://www.depressedpress.com/Assets/Art/TopArrow.gif[/img][/link] | ![]() |
BBCode lists come in two basic forms: unordered (or bulleted) lists and ordered (numbered or alphabetized) lists. In both cases the same basic formatting applies. The list tags contain any number of "item" tags ("[*]"). An item tag is placed before each item in the list and does not require and end tag. Here are the types of lists followed by the HTML that they produce:
List Type | BBCode | Result |
Unordered List | [list] [*]Item One [*]Item Two [*]Item Three [/list] |
|
Numbered List | [list=1] [*]Item One [*]Item Two [*]Item Three [/list] |
|
Numbered List (Small Roman Numerals) |
[list=i] [*]Item One [*]Item Two [*]Item Three [/list] |
|
Numbered List (Large Roman Numerals) |
[list=I] [*]Item One [*]Item Two [*]Item Three [/list] |
|
Alphabetized List (Lowercase) |
[list=a] [*]Item One [*]Item Two [*]Item Three [/list] |
|
Alphabetized List (Uppercase) |
[list=A] [*]Item One [*]Item Two [*]Item Three [/list] |
|
A list must have at least one item tag ("[*]") in it to be valid. In addition the there can be no text between the beginning list tag and the first item tag ("[list][*][/list]" is correct while "[list]MyList [*][/list]" will fail).
Lists can be nested together as deeply as you like, but each nested list must be a list item of the outer list. Here's an example of nesting:
List | BBCode | Result |
Unordered List | [list] [*]Item One [list=1] [*]Item One [*]Item Two [list=I] [*]Item One [*]Item Two [*]Item Three [list=i] [*]Item One [*]Item Two [*]Item Three [/list] [/list] [*]Item Three [/list] [*]Item Two [*]Item Three [/list] |
|
List items may use any formatting or link tags that you wish and may include images. Lists themselves however may only be contained in other list tags.
Smilies, also know as "emoticons" are expressive codes appended to text. They are generally seen as small picture turned 90 degrees to the right so that ":^)" is a "smiling face". There are many different kinds of smilies and some can become very, very elaborate. The forums' BBCode parser can convert a subset of these smilies codes into graphical images. Most of the smilies have at least one alternative way to type it and some have several. For our purposes all smilies are made up of three characters however (generally "eyes", "nose" and "mouth").
Here is a list of the smilies supported by our BBCode parser and the graphic that will replace it:
Meaning | What to Type | Classic Set |
Very Happy | :D | ![]() |
Smile | :) | ![]() |
Sad | :( | ![]() |
Surprised | :o | ![]() |
Shocked | :shock: | ![]() |
Confused | :? | ![]() |
Cool | 8) | ![]() |
Laughing | :lol: | ![]() |
Mad | :x | ![]() |
Razz | :P | ![]() |
Embarassed | :oops: | ![]() |
Crying or Very sad | :cry: | ![]() |
Evil or Very Mad | :evil: | ![]() |
Twisted Evil | :twisted: | ![]() |
Rolling Eyes | :roll: | ![]() |
Wink | :wink: | ![]() |
Exclamation | :!: | ![]() |
Question | :?: | ![]() |
Idea | :idea: | ![]() |
Arrow | :arrow: | ![]() |
These forums use a component written by Jim Davis, author of the DP_ParseBBML coldfusion custom tag.
DP_ParseBBML translates a customized dialect of Bulletin Board Markup Language ("BBML", originally created for use in the popular Ultimate Bulletin Board™) in to browser-ready HTML markup. BBML is easy to learn and use and gives end users safe access to many of HTML's formatting controls.