WordPress HTML editing: a boogeyman?
Hold your horses…
It’s not like that.
We all know that WordPress is very flexible. Depending on the tools you use (themes, WordPress builders, plugins, add-ons, widgets) you can play with blocks and drag and drops. No coding required.
From time to time you might want to tweak things a little bit, and then some HTML knowledge might come in handy.
Usually, HTML code doesn’t come alone. You will need CSS as well. While HTML will deal with the website structure, CSS handles the styling part.
Before starting with WordPress HTML editing
Before jumping into any editing, you need to take some precautions.
First, make sure you know what you want to accomplish: test something, make some advanced editing?
If you want to alter WordPress theme code, it’s usually recommended to work with a child theme and avoid going straight live.
Now, you don’t need to be the most skilled front-end developer to deal with HTML when changing pages or posts code. There are a lot of resources out there that can easily teach you the basics. I took this Khan Academy course and loved it! If I have any questions I rely on Stackoverflow and W3Schools.
And you know what? It’s darn cool when you don’t need to rely on others to do tiny website or email changes.
How to Edit HTML in WordPress
Editing your HTML can be pretty safe. But it would still be smart to create backups before doing anything.
Now, let’s see how things will play out when we use:
- HTML editing in the classic WordPress Editor (TinyMCE)
- WordPress HTML Editing via shortcodes
- HTML Editing in the WordPress Block Editor (Gutenberg)
- WordPress HTML editing using Widgets
- HTML editing in the WordPress Customizer
- Editing your WordPress theme source code
- Intro to the most popular HTML tags
HTML editing in the classic WordPress Editor (TinyMCE)
Usually, you would edit a page or a post in the Visual Editor, like below.
The Visual Editor icons allow you to format text, insert lists and links, and more.
Now, every time you edit something in here, behind the scenes, there is some HTML markup happening.
For example, you are adding an image, behind it you’ll see an <img> tag.
If you are adding a list of items, in HTML mode you’ll see these tags <ol> or <ul>, and <li>.
How can you access this code? Through switching from the Visual Editor to the Text Editor.
You could work with both tools, and just add some extra markup in the Text Editor, if you want.
The Text Editor comes along with some other benefits as well.
With proper schema markup you can gain some SEO advantages.
Here you can even add different styling through CSS.
For those that are more familiar with HTML and used tools such as Sublime for coding, you can rejoice because there’s a tool out there that can help out with getting similar results: HTML Editor Syntax Highlighter.
Careful though, they haven’t updated it in a while now, you might encounter some issues….
WordPress HTML Editing via shortcodes
WordPress builders such as Colibri may allow you to alter HTML code via shortcodes. This means you can install the Shortcoder plugin that will let you insert HTML code via the Customizer.
- This means you can install the Shortcoder plugin that will let you insert HTML code via the Customizer. More details about this method here.
HTML Editing in the WordPress Block Editor (Gutenberg)
In the Gutenberg experience, you can also switch from the Visual Editor to a text one (the Code Editor).
- You can also edit blocks individually as HTML. You also have a custom HTML block.
Pretty neat, don’t you think?
WordPress HTML editing using Widgets
HTML editing in the WordPress Customizer
Widgets are available in the WordPress customizer as well. There are different approaches from theme to theme.
Editing your WordPress theme source code
Careful with this one, guys!
You can access the Theme Editor in the menu under Appearance. The moment you select it you are warned: editing directly here might result in breaking your site. This is why it’s recommended to make a child theme.
There are more files that you can alter: js, PHP, and CSS as well.
Intro to the most popular HTML tags
Now, let’s dwell a bit into the most popular HTML tags that you could use.
For every open tag, there is a matching closing tag. The symbol for opening a tag is this one: “<”, when you close them you usually repeat the tag and add this symbol “/>”.
Let’s look at some examples:
The basic text gets inserted in between paragraph (p) tags, like this:
<p> – I opened a paragraph tag
</p> – I closed the paragraph tag
The end result:
- I used CodePen for the exercise.
- Now, WordPress makes things even easier for you. Just click on “img” in the menu and it will prompt you to a window where you insert your URL.
- The heading tags can go from <h1> to <h6>, depending on the importance of the reading. there are 2 more tags that can be used for headings and paragraphs as well: <strong> for bold text and <em> for italic text.
- In HTML you have the <ol> tag for ordered lists, and the <ul> tag for the unordered one. The things that get listed go inside <li> tags, as below.
For this you use the <a> tag with a link as a reference:
Now, going back a bit to WordPress, the Text Editor is making your life even easier.
You do not need to manually insert your <img> tag, you just select it from the menu and paste the URL there, or simply add your image from the “Add Media” option and it will automatically add the HTML code for you.
HTML doesn’t look like rocket science, does it? Now, you might wonder about styling a bit…The examples above don’t look too nice, do they? For that, you need some CSS. We’ve covered this aspect in a previous article, make sure to check it out!
Now, do you really need to alter your HTML code?
Do you have the skills to change the code?
Isn’t anything that you could do via your theme options and additional plugins?
What about using a WordPress builder? It can give you endless possibilities.
Always think twice before such a decision and use backups!
In my personal opinion, the Text Editor in the classic WordPress editor or the Code Editor in the Gutenberg version usually suffices.
Over and out!