Site logo

Archived topic

Sections remove a tags

7 replies · Started by Nikola on April 18, 2019

Viewing posts 1–8 of 8

When i change from visual editor to text editor in sections my "a" tags are deleted. I want to create a hover, clickable block with content inside of that block.

Thanks in advance.

Best regards
Nikola

Hi there,

Are you trying to wrap block elements (<div> etc..) in the <a> elements? If so, that's not valid HTML, and WordPress will strip it from your code (unfortunately).

Yes, that i want to achieve. Do you know another way?

Hi there,

do you have an example of what you're trying to achieve?

Something like this.

<a class="box" href="#">
     <div class="content">
     <h2> Text </h2>
     <p> text </p>
     <span> Learn more</span>
  </div>
</a>

Imagine clickable box with content inside of that box. And i want to make entire box (block) clickable, not just "Learn more" link for example.

So instead try this:

<div class="box">
    <h2>Text</h2>
    <p class="box-text">Text</p>
    <span class="box-span">Learn more</span>
    <a class="box-link" href="#"><!-- link --></a>
</div>

Then this CSS:

.box {
    postition: relative;
    /* Add box styles here */
}

.box-link {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

The editor may throw in a random P tag but it should do the trick and if the span has a class and the a tag has a comment inside it won't strip them out.

Great. It works! Thank you, David. :)

Awesome - glad to be of help :)

This archived topic is closed to new replies.