What is This All About?

When you participate on forums discussions, sometimes to type plain text would make it, but often, you need to make your posts more interesting: to add styles, change fonts, play with colors, insert links or to display images ...

In web development, HTML is used for all that, but in forums posts, a simplified code inspired from it allows users to format text, that code's called the "bbCode".

This blog will help you easily understand & use bbCode. Have Fun!!! :)

ps: don't hesitate to post a comment for any help needed or a suggestion, or just to say hi! :)

Thursday, October 4, 2007

Insert Codes into Your Posts

Note: If this lesson seems a bit unclear to you, you may want to check basic bbCode lessons: How Does bbCode Work? & How to Correctly Insert Tags.

You can insert HTML, PHP, Javascript codes, etc into special boxes using bbCode, the text inserted in the code box will be converted to a fixed-width (monospace) font, & ensures that nothing from the code is lost when you submit your message.

The tag for code is [code]. Its use is not different from the use of other tags we saw, it should wrap the code you want to be in the box.

Example:

Let's wrap an example of Javascript code:

[code]
<script type="text/javascript">
<!-- alert("Hello world!"); //-->
</script>
[/code]

Here's the result you would get:

Code:
<script type="text/javascript">
<!--
alert("Hello world!");
//-->
</script>

2 comments:

C-ten said...

There's a lot of great tutorials here, but here's one I couldn't find.

How do you do a Code Box with a "Select All" option? Instead of having "Code:" at the top of the box it has "Code: Select All" and the user can click and automatically highlight everything in the code box. I've looked and looked to see how this is done and I can't seem to find it anywhere.

Mumu said...

If such a tag exists I'm not aware of it, as I said in some posts, bbCode is derived from HTML but it's very limited & allows you to do basic stuff .. but to get text selected with one click even HTML is not enough, it's done using Javascript :)

Sorry for the late reply I was busy with other stuff, & thanks for the compliment :)