Template:CodeBlock
From Valve Developer Community

This template formats the text as a block of code.
Parameters and Examples
Main
The main parameters are described below.
Name | Description | Example | Preview |
---|---|---|---|
{{{1}}} | Your code. It is recommended to wrap the template content with the <nowiki> tag. |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|Hello, World!}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; Hello, World! |
{{{margin}}} | Controls margins. Goes clockwise. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|margin=5px 30px 0 10px|Hello, World!}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; Hello, World! |
{{{style}}} | The style of the template. The following styles are available:
|
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|style=1|Hello, World!}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; Hello, World! |
{{{height}}} | Controls the height of the block. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|height=52px|<nowiki>1. Hello World
2. Hello World
3. Hello World
4. Hello World</nowiki>}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; 1. Hello World
2. Hello World
3. Hello World
4. Hello World |
{{{width}}} | Controls the width of the block. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|width=50%|<nowiki>1. Hello World
2. Hello World
3. Hello World
4. Hello World
5. Hello World </nowiki>}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; 1. Hello World
2. Hello World
3. Hello World
4. Hello World
5. Hello World |
{{{lines}}} | Manual: Numbered lines. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|lines=4|<nowiki>Hello World
Hello World
Hello World
Hello World</nowiki>}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; Hello World
Hello World
Hello World
Hello World |
{{{start}}} | What number to start numbering from (default value is 1). The value can be negative. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|start=12|lines=5|<nowiki>Hello World
Hello World
Hello World
Hello World
Hello World</nowiki>}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; Hello World
Hello World
Hello World
Hello World
Hello World |
{{{highlight}}} | Adds syntax highlighting for the language specified. ![]() |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|highlight=c|int main() {return 0;} }} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; int main() {
return 0;
} |
Header
The parameters for adding a header with the code source and the name of the programming language are described below.

Name | Description | Example | Preview |
---|---|---|---|
{{{src}}} | The source of your code. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|src=light.rad|forcetextureshadow props_foliage/urban_tree01.mdl}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; forcetextureshadow props_foliage/urban_tree01.mdl |
{{{lang}}} | The name of the language displayed on the right side of the header. | <div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; {{CodeBlock|lang=csharp
|<nowiki>using System;
namespace HelloWorld
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
}</nowiki>}} |
<div style="display:flex;justify-content:space-between;background-color:rgba(0,0,0,.1); border-bottom:1px solid rgba(255,255,255,.1); font-family:monospace,monospace;line-height:1.125rem; text-indent:0; using System;
namespace HelloWorld
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
} |
The above documentation is transcluded from Template:CodeBlock/doc. (Edit | Page history)
Editors can experiment in this template's sandbox (edit) and testcases (create) pages.
Editors can experiment in this template's sandbox (edit) and testcases (create) pages.
Hidden category: