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>

Read More

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?

Related posts

Leave a Reply

2 comments

  1. 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>