Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to edit HTML in wordpress

Getting Started with WordPress and HTML

Whether you're a budding programmer or a seasoned developer, WordPress is a platform that you will, inevitably, come across. WordPress is the most widely used Content Management System (CMS), powering over a third of all websites on the internet. The beauty of WordPress lies in its user-friendly interface that even beginners can handle, and its flexibility, due to HTML, CSS, and PHP, to accommodate more advanced users.

HTML (HyperText Markup Language) is the standard markup language for creating web pages. It's like the skeleton of a website, defining its structure and contents.

Let's get started on how to edit HTML in WordPress.

Accessing HTML in WordPress

WordPress, by default, has a visual editor, that allows you to format text, add links or images without touching any code. But sometimes, you might need to customize your site beyond what the visual editor can handle. That's where HTML comes in.

To access HTML on WordPress, you'll first need to navigate to the page or post that you want to edit. On the top right corner of the editor, you'll see two tabs: 'Visual' and 'Text'. Click on 'Text' to switch to the HTML editor.

<!-- This is what you'll see in the HTML editor -->
<h2>Welcome to my blog</h2>
<p>This is a sample blog post.</p>

Making Basic Changes

Changing Text Size

Let's say you want to change the font size of a heading. In HTML, headings are defined by the <h1> to <h6> tags. <h1> is the largest heading, and <h6> is the smallest.

Here is how to change a heading from <h2> to <h1> to make it bigger:

<!-- Before -->
<h2>Welcome to my blog</h2>

<!-- After -->
<h1>Welcome to my blog</h1>

To add a link, you'll use the <a> tag (short for 'anchor'). You'll also need the href attribute to specify the web address.

Here is how to add a link:

<!-- Before -->
<p>Check out my latest post.</p>

<!-- After -->
<p>Check out my <a href="">latest post</a>.</p>

Embedding Images

Images can be embedded into your WordPress posts or pages by using the <img> tag. The src attribute is used to indicate the image source or the URL of the image.

Here's how to embed an image:

<!-- Embedding an image -->
<img src="" alt="Sample Image">

The alt attribute is used to provide alternative text for the image, should it fail to load. It's also used to improve accessibility for people using screen readers.

Adding CSS

CSS (Cascading Style Sheets), another language used in web development, is used to style HTML elements. You can add inline CSS to your HTML elements in WordPress using the style attribute.

Here's how to change the color of a paragraph to red:

<!-- Before -->
<p>This is a sample paragraph.</p>

<!-- After -->
<p style="color:red;">This is a sample paragraph.</p>

In Conclusion

Editing HTML in WordPress allows for more flexibility and customization beyond what the visual editor can provide. But remember, always back up your site before making any major changes, as even a small mistake can break your site.

Understanding and utilizing HTML in WordPress is like learning a new language, it may seem intimidating at first, but with practice and patience, it becomes a powerful tool in your web development arsenal. Happy coding!