How to Add Custom HTML in WordPress

WordPress is a straightforward Content Management System (CMS). Most of the time, you won’t need to touch a single code to post content on your website. But, there are advanced tasks that require you to tweak a couple of HTML codes on the editor, hence, understanding HTML can be helpful.

So sit back, and relax. This article will explain how you can add HTML codes on your WordPress website.

What is HTML?

It stands for Hypertext Markup Language, which is the backbone of website creation.

HTML allows you to organize online documents using tags and attributes — a set of codes. They’ll then be saved as an HTML file. Whenever a browser opens the file, it displays only the readable text, which means no tags are shown.

When dealing with HTML, keep in mind that most elements have opening and closing tags like paragraphs, <p>an example</p>. However, there are a few self-closing tags as well such as line breaks, <br>.

Why Do You Need to Add HTML in WordPress?

WordPress’ new editor, Gutenberg, offers a more intuitive way to handle content formatting. Not only that, inserting media files like images or videos, adding layout elements and widgets are doesn’t take a minute. In short, using the default editor is enough for basic formatting needs.

However, there’s a drawback. To handle specific tasks, relying on the default editor alone can be challenging. For example, there are times when you might want to create a custom table, modify images, add borders, etc., for aesthetic purposes.

In any of these situations, inserting custom HTML code in your WordPress’ post can be a good option.

How to Add HTML in WordPress (with Examples)

There are three common ways on how you can add custom HTML codes on WordPress. Either for posts, pages, or as widgets.

Adding HTML in WordPress Posts

If you want to insert HTML codes to your posts, please follow these steps:

  1. Log in to your WordPress dashboard.
  2. Click All Posts, from the navigation menu.
    wordpress html
  3. Choose the post you want to edit, and you’ll be directed to the WordPress visual editor.
    wordpress post
  4. Click the Plus iconon the block area or the top of the editor.
  5. Choose the Custom HTMLicon under the Formatting
    custom html
  6. Alternatively, you can switch to the editor mode. Click the three dots menuon the top right side corner, then select Code Editor.
    testing post
  7. Feel free to add your desired code. As an example, the code for making a simple table will be used.
    <table style="background-color: #87ceeb;">
      <tbody>
        <tr>
          <td>Games</td>
          <td>Ranking</td>
        </tr>
        <tr>
          <td>PUBG Mobile</td>
          <td>1</td>
        </tr>
        <tr>
          <td>Stardew Valley</td>
          <td>2</td>
        </tr>
      </tbody>
    </table>
    
  8. The result will look like this:
    wordpress preview html post

Adding HTML in WordPress Pages

This method has a similar process to WordPress posts. The steps are:

  1. Click All Pages on your WordPress dashboard.
    all pages
  2. Add a new page or edit an existing one.
  3. Click thePlus icon, either on the block area or from the top of the editor.
  4. Select the Custom HTML optionunder the Formatting Another way is by picking from the Most Used segment or switching the editor mode to Code Editor.
  5. Add the custom HTML code to modify your WordPress page.
    custom html
  6. Click Preview if you want to see the results before publishing.
    preview wp post before publishing
  7. Here is the outcome:
    outcome

Adding HTML in WordPress Widgets

To insert HTML code in your widgets, please do the following:

  1. From the WordPress dashboard, go to the Widgetspage under the Appearance menu.
    appearance
  2. Choose the Custom HTML option and click Add Widget.
    add wp widget
  3. Fill out the widget’s title and insert your HTML code.
    html code
  4. Savethe changes.
  5. The result:
    result

Extra Tips

You’ve learned how to add HTML in WordPress. It’s not as hard as it seems, right? Before you continue, there are important keys that you need to keep in mind.

Always Use the Clean Code

There is a time when you don’t write the code from scratch in WordPress, but copying from other sources like Google Docs. This is fine.

However, make sure to clean up any borrowed characters from those sources like  for line breaks, or <span style=”font-weight: 500;”> </span> for span style.

It’s necessary because too many cluttered characters will affect your site performance.

Learn More HTML Tags

It is recommended to learn basic HTML tags. With this knowledge you can cover elemental needs for making attractive content. Here are a few of the basics:

  • Headings: <h1>, <h2>, <h3>, <h4>, <h5>, <h6>
  • Unordered lists: <ul>
  • Ordered lists: <ol>
  • Inserting Images: <img>
  • Inserting links: <a>

Conclusion

Adding HTML in WordPress is easy peasy, of course if its not overcomplicated tarot website with modern animations like Tarotoo. Just make sure that the code is correct. You can add HTML codes either on your posts/pages or widgets.

However, if you’re only dealing with basic formatting and insertion, the WordPress default editor can handle the trick.

Happy customizing!