Published by
Nov 29, 2009 (last update: Dec 12, 2011)

How to use tags

Score: 4.2/5 (181 votes)
*****
This article will show you the common types of tags and how to use them.

1.) Source Code Tags


Syntax:
[code]int main() {
    return 0;
}[/code]

Becomes:
1
2
3
int main() {
    return 0;
}


Use this whenever you post code, as it provides coloring most people are used to, as well as preserving indentation (a Good Thing).

You can also make it start at a specific line number (10, in this example) by doing this:
[code firstline=10]//start in the middle of some function
for(unsigned int i = 0; i < 5; ++i) {
do_something(i);
}[/code]

This becomes:
10
11
12
13
//start in the middle of some function
for(unsigned int i = 0; i < 5; ++i) {
    do_something(i);
}


One warning however, long code lines will simply stretch the box, so try to avoid using overly long lines of code.

2.) Output Tags


Syntax:
[output]Code Output Goes Here
1234567890[/output]

Becomes:
Code Output Goes Here
1234567890

Use this if you have output that you want to display from your code, e.g.: expected results, actual results.

1/2.) Combining the Above


If you have a short piece of code and output you wish to display, you can use the following format:

[code]int main() {
    std::cout<<"Hello World!"<<std::endl;
    return 0;
}
---
Hello World!
[/code]

Becomes:
1
2
3
4
int main() {
    std::cout<<"Hello World!"<<std::endl;
    return 0;
}
Hello World!


3.) Quotation Tags


Syntax:
[quote]Quote goes here.[/quote]

or to more easily quote a specific person:
[quote=Somebody]I didn't say that!![/quote]

Becomes:
Quote goes here.

or
Somebody wrote:
I didn't say that!!

Use this to quote other people or stuff from another site. This makes it more obvious as to what exactly was said.

4.) Teletype Tags


Syntax:
[tt]abcdefghij
1234567890[/tt]

Becomes:
abcdefghij
1234567890

This tag is quite similar to the Code Output tag, shown above, except it does not have a box surrounding it, and will delete excess whitespace at the beginning of a line.

5.) Miscellaneous Tags


This section contains the tags that simply alter the appearance of the text.

Bold:
[b]Text[/b]    =>    Text
Italic:
[i]Text[/i]    =>    Text
Underline:
[u]Text[/u]    =>    Text
Small:
[small]Text[/small]    =>    Text
Subscript:
[sub]Text[/sub]    =>    Text
Superscript:
[sup]Text[/sup]    =>    Text

6.) More Information


When using the "Tags:" selector on the right side of the post area, select the information you want to quote, italicize, etc, and then click on the respective button. This causes the tags to surround the selected text, rather then simply be added at the end of your post.