ehsan shirzadi
ehsan shirzadi

Reputation: 4859

Wordpress add extra tags to my HTML in page

I try to add this HTML inside a Wordpress page in Text tab:

<div class="homepage-section-row" style="margin-top:5px">
<a href="#">
    <p>Test</p>
    <span class="icon-comment-alt fblock-icon"></span>
</a>

But when I see the page source, I see some extra tags:

<div class="homepage-section-row" style="margin-top:5px">
<a href="#"><p></p>
<p>Test</p>
</a><p><a href="#">        <span class="icon-comment-alt fblock-icon"></span><br>
</a>
</p></div>

I'm using Wordpress 4.1. What should I do?

Upvotes: 1

Views: 1016

Answers (2)

Stickers
Stickers

Reputation: 78676

In Wordpress text editor, any block level like <div> <p> <ul> elements will be reserved, any inline elements like <a> <span> will be automatically wrapped in to <p> tags if there are line breaks surrounded.

What you could do is make everything one line:

<div class="homepage-section-row" style="margin-top:5px"><a href="#"><p>Test</p><span class="icon-comment-alt fblock-icon"></span></a></div>

OR this is also acceptable:

<div class="homepage-section-row" style="margin-top:5px">
<a href="#"><span>Test</span><span class="icon-comment-alt fblock-icon"</span></a>
</div>

OR update the html tags if you want to have multiple items:

<ul class="homepage-section-row">
    <li><a href="#">Test 1</a></li>
    <li><a href="#">Test 2</a></li>
</div>

Upvotes: 2

Jacob Raccuia
Jacob Raccuia

Reputation: 1686

It's called wpautop. I also find it incredibly annoying, but when you have a website with a lot of writers, it is very useful.

Here is a plugin I have used to turn it off - HTML Markup Editor

Upvotes: 1

Related Questions