BLACK FRIDAY: 50% OFF all Pro plans
Pro from $18 a year or $60 lifetime, no code needed
Ends Cyber Monday, 30 Nov. Lock in the price today
Get 50% Off
Guide

Code Block Free

How to set up and style the Code Block widget in Elementor.

Code Block shows code with syntax colors for 25 languages, line numbers, highlighted lines, a file name and a copy button. Choose a dark or light theme and change every color to match your site.

Part of: Bright Addons (free).

Set it up

  1. Drag the Code Block widget onto the page.

  2. In Code, choose the Language and paste the Code.

  3. Type a File Name and keep Line Numbers on.

  4. Add Highlight Lines if you want to mark lines.

  5. Keep Copy Button on.

  6. In the Style tab, choose the Color Theme and Max Height.

Content options

Code

Option What it does
Language 25 languages, or plain text.
Code The code. It is shown exactly as typed and never run.
File Name Shown in the top bar.
Show Language Shows the language name in the top bar.
Line Numbers Shows numbers next to each line.
First Line Number The number of the first line.
Highlight Lines Line numbers to mark, separated by commas. Ranges like 5-7 work too.
Wrap Long Lines Off: long lines scroll sideways.
Copy Button Adds a button that copies the code.
Copy Text Text of the button.
Copied Text Text shown after copying.
Bright Addons Pro

Like this free widget? Get 70+ more with Pro

Pro adds 77 widgets, 10 extensions, a Theme Builder and 32 dynamic tags, and keeps every free widget. From $16 a year, with a 14-day money-back guarantee.

Style options

These sections are in the Style tab.

  • Box

    color theme, max height, border radius, shadow, code typography and padding.

  • Colors

    background, text, top bar, keywords, text in quotes, functions, numbers, comments, tags and properties, line numbers and highlighted line.

Tips

  • The code is printed as text, so HTML and PHP in it are never run on your site.

  • The highlighter is loaded only on pages that use the widget, and it does not change other code on the page.

  • Without JavaScript the code still shows, just without colors.

Questions and answers

Which languages are supported?

HTML and XML, CSS, SCSS, JavaScript, TypeScript, JSX, TSX, JSON, PHP, Python, Bash, SQL, YAML, Java, C, C++, C#, Go, Ruby, Rust, Diff, INI, Dockerfile, Nginx and Apache.

Is the code run on my site?

No. It is shown exactly as typed and never run.

Can I mark important lines?

Yes. Type the line numbers or ranges in Highlight Lines.

Need more help?

Check the troubleshooting guide, or contact support with the page address and what you expected to happen.

Troubleshooting guide
All guides