Add HTML, CSS & JS Code to WordPress Page/post
Are you unable to add the HTML, CSS, and JS code to the WordPress page and display the output? If you add HTML, CSS, and JS code to your WordPress source code in the classic editor then only your HTML code will work. I have 2 best solutions for this problem, which I will tell you in this article. So, this article is about how to add HTML, CSS, and JS code to a WordPress page. In a project, I created using HTML, CSS, and JS code, I researched how to run output on WordPress pages. When researching how to display the output of my project created using HTML, CSS, and Js on a WordPress page. I couldn’t display the output on my WordPress page, then I found two solutions. Both methods will work for you, no matter how you code these three programming languages together and separately.
One of those two methods requires a plugin and the other does not require a plugin. If you want to use them without the plugin method, you need to merge the CSS and JS code into the HTML. With the plugin method your HTML, CSS, and JS code can be separate too. Let’s see those two easy methods for adding codes to WordPress pages.
1. Add code to the WordPress page Without using a plugin
Note: Follow this method only if you are using block editor else use the next method.
Step 2. Login to your WordPress dashboard. Add a new page to add your custom HTML, CSS, and JS. Create new pages by pages > add new page in the left menu. Once inside the WordPress page, click on the add + icon (add block inserter) at the top.
Step 3. Search custom HTML in the search box and click on custom HTML to add it.
Step 4. Paste your combined HTML into the custom HTML box. Then click to preview the page and the output of your custom HTML code is successfully displayed on the WordPress page.
If you want the output of your code to be displayed throughout your page, Give it “full width” in the content layout in your page theme setting. And change “no sidebar” in the theme sidebar setting. If you do this, the output of your code will display on full-page, Only your header and footer are visible.
So, if you think this method is difficult for you and have a problem merging CSS and Js code in HTML then try it next method. In the next method, you can display/run the output on your WordPress page without merging your HTML, CSS, and JS code. So let’s see how to add HTML, CSS, and JS code to the WordPress page using the plugin and display the output on the page.
2. Add code to the WordPress page By using a plugin
Step 1. In this method, you first install and activate the plugin called “WP-CODER“. It is the best plugin to add HTML, CSS, and JS code to WordPress pages/posts. Because you can easily add code of these three languages to it and see your output.
Step 2. After you activate the wpcoder plugin, the Wow plugin option will be newly added to the WordPress menu. G0 to wow plugin > wp coder.
Step 3. Add your HTML, CSS, and JS code with this plugin. So, Click the add new button above.
Step 5. After pasting your code click the save button. To display the output of this code on your WordPress page, copy your shortcode as shown below figure and paste it onto your WordPress page.
After pasting your shortcode on the page, then publish your page and see that the output of your HTML, CSS, and JS code is successfully displayed on your page. You can use these 2 methods, If you have a website related to coding, you can provide the code in your post and display the output to the user using this method. You can display the output to your user and interpret the code.