Adding code in box on the forum

In summary, To add code in a box on the forum, you can use the <code>code</code> or <code>pre</code> HTML tags. These tags will display your code in a formatted box, making it easier for others to read and understand. Yes, you can add syntax highlighting to your code by using a <code>class</code> attribute on your <code>code</code> or <code>pre</code> tags. You can make your code box stand out by adding a <code>style</code> attribute to your <code>code</code> or <code>pre</code> tags. This will allow you to customize the look of your code box with different colors
  • #1
gfd43tg
Gold Member
950
50
Hello,

I am taking MATLAB this summer and will be having a number of questions on this forum about all my bugged code when I make it. Before I begin, I was wondering how do people add those ''code boxes'' when they make a thread that shows all their code within the post.

Thanks

Example: Post #2 in https://www.physicsforums.com/showthread.php?t=756681
 
Physics news on Phys.org
  • #2
Just use [noparse]
Code:
[/noparse] tags:

[noparse]
Code:
Matlab
   code
[/noparse]

displays as

Code:
Matlab
   code
 
  • Like
Likes 1 person

1. How do I add code in a box on the forum?

To add code in a box on the forum, you can use the code or pre HTML tags. These tags will display your code in a formatted box, making it easier for others to read and understand.

2. Can I add syntax highlighting to my code in the forum?

Yes, you can add syntax highlighting to your code by using a class attribute on your code or pre tags. There are many different syntax highlighting libraries available, so make sure to choose one that is compatible with your forum's formatting.

3. How can I make my code box stand out on the forum?

You can make your code box stand out by adding a style attribute to your code or pre tags. This will allow you to customize the look of your code box with different colors, borders, and fonts.

4. Is there a character limit for adding code in a box on the forum?

This depends on the specific forum you are using. Some forums may have a character limit for posts, while others may not. It's best to check with the forum guidelines or ask a moderator for clarification.

5. Can I edit my code box after I have posted it on the forum?

Most forums allow you to edit your posts, including any code boxes you have added. However, it's important to note that editing code may change the formatting or functionality, so it's best to double-check your code after editing and make any necessary adjustments.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
858
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
272
Back
Top