Opened 4 years ago
Closed 20 months ago
#38055 closed defect (bug) (wontfix)
<a href> tags disappear when switching from "Text" view to "Visual" view of Page Editor
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6.1 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
When editing a page, I make a clickable <div> surrounded by a <a href> tag. When someone else then edits the page but edits using the Visual tab, the links I had previously entered disappear.
When I put the <a href> tags back in and update the page, just switching between the Visual and Text tabs in quick succession removes any and all <a href> tags from the code.
I have tried disabling wpautop with no effect.
Is there a solution to this, or will I have to replace all the <a href> tags every time someone else edits the page?
Change History (2)
#5
@
20 months ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
I agree that <a href="..."><div>...</div></a>
is valid HTML5. Unfortunately, due to the nature of wpautop()
, I don't think it's possible to add support for this use case. Particularly with the introduction of the block editor (which deprecates the classic editor and wpautop()
), it's unlikely that this issue will be addressed.
For the second case of <a href="..."></a><div>...</div>
, this is intended behaviour by the classic editor. Empty inline tags will be automatically removed. To prevent this, I recommend putting a
character inside the tag.
This is an issue for me as well. One site has a custom theme that is out of date and planned to be replaced. I hoped the issue only happened there but I tried it on other sites with Generatepress and Twentynineteen and same problem.
<a> tags around <div> tags has been legitimate since HTML 5 and should be allowed.
Here are two test cases:
The a tag pair and the div pair will be removed and replaced with in visual editor
with some css to expand the a tag to cover the div, this gets removed in the visual editor.
This is happening in WP 5.1.1