How to Add Code in Elementor

How to Add Code in Elementor

Last modified: June 3, 2026

Fiverr freelancers

Elementor includes an HTML widget that lets you add custom HTML, CSS, and JavaScript directly to any page or post from inside the visual editor. This is how you add code snippets, embed tools, include tracking pixels, or run small custom scripts without installing a plugin or editing your theme files. This guide explains when to use the HTML widget and how to add it to your pages.

Show More

* This button will show the rest of the post and open up an offer from a vendor

Why Add Code in Elementor WordPress Website?

There are a few common scenarios where adding code directly to an Elementor page is the right approach rather than installing a plugin:

  • Third-party embed codes. Booking widgets, chat tools, calculator embeds, and similar services provide a code snippet that needs to be placed in a specific location on a page. The HTML widget places it exactly where you want it in the Elementor layout.
  • Custom tracking pixels. Some advertising pixels (like Facebook’s pixel for specific page events or Google Analytics goals) need to fire on a particular page element or action. These go into the HTML widget rather than the site-wide header.
  • Inline CSS overrides. When a style change is too specific for Elementor’s built-in controls, a small inline CSS block in the HTML widget handles it without modifying your theme files or adding a separate stylesheet.
  • Script-dependent features. If a feature requires JavaScript to work (like a custom countdown timer, a dynamic text switcher, or an animation trigger), the HTML widget accepts JavaScript wrapped in script tags.

Is There Not a Plugin to Fill the Gaps?

One of the factors that many people like about WordPress is that it can be extended using plugins. There are plugins for all kinds of functions like appointments, social media, SEO, pop-ups, and more. However, that doesn’t mean that there is a plugin for everything (although there is a common joke about there being that way).

And some plugins/themes don’t work together.

Another problem is that using a plugin for a simple problem, as mentioned above, is a misuse of resources. Plugins cost time to load and for every second that it takes to load a website, you will lose 7% of your revenue.

Some plugins have been found to increase loading times by up to 31%, namely SEO, eCommerce, and security plugins. However, most have caused some increase in loading times. By removing multiple plugins and installing only the code required for the function, website owners can improve loading times and keep websites loading within the recommended 2 seconds.

How to Add Code in Elementor

Elementor’s HTML widget is available in the Free version of Elementor. To add it to a page:

  1. Open the page in the Elementor editor (go to the page in WordPress admin, hover over it, and click Edit with Elementor).
  2. In the left-hand widget panel, search for HTML in the search box.
  3. Drag the HTML widget and drop it onto the section of the page where you want the code to appear.
  4. In the left panel, you’ll see an HTML Code text area. Paste your HTML, CSS (wrapped in <style> tags), or JavaScript (wrapped in <script> tags) into this box.
  5. The page preview will update to reflect what your code produces. Adjust the placement by dragging the widget within the section as needed.
  6. Click Update or Publish to save.

Note: Some advanced JavaScript may not preview correctly inside the Elementor editor but will work correctly on the published page. If you’re testing a script, publish the page and check the live version rather than relying on the editor preview.

Final Word: How to Add Code in Elementor

The HTML widget is one of Elementor’s most practically useful features for advanced customization. Once you know where to find it, adding any HTML snippet, inline CSS override, or JavaScript block to a specific page takes about 30 seconds. It’s particularly useful for third-party embed codes and tracking pixels that need to be placed at a specific point in the page layout rather than in the global site header.

If you need to add a shortcode from another plugin rather than raw HTML, the Elementor Shortcode widget handles that separately. See our guide on how to add a shortcode in WordPress Elementor for that workflow.

Recap:
Save 4 Later
Email liked links to yourself

    Stay Updated with WordPress Insights

    Get the latest WordPress tips, theme reviews, and industry deals delivered to your inbox.