Opened 13 years ago
Closed 12 years ago
#20089 closed defect (bug) (fixed)
Visual editor messes up links in headers
Reported by: | jikamens | Owned by: | |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.3.1 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
Create a new post.
In HTML mode, put this in the post:
<h2><a name="foo" href="#bar">Foo</a></h2>
Switch to Visual mode.
Switch back to HTML mode.
Note how it now reads:
<h2><a name="foo" href="#bar"></a>Foo</h2>
I.e., the "</a>" tag has been moved, and the header is no longer a link.
This doesn't happen if you leave off the "name='foo'".
Change History (8)
#2
follow-up:
↓ 3
@
13 years ago
- Keywords close added
<a name="foo" href="#bar">
is not a link, it is an anchor. In HTML typically anchors don't wrap any text, so whether it's <h2><a name="foo" href="#bar">Foo</a></h2>
or <h2><a name="foo" href="#bar"></a>Foo</h2>
or even <a name="foo" href="#bar"></a><h2>Foo</h2>
it works the same way (scrolls the page to it).
Proper links <h2><a href="http://site.com#bar">Foo</a></h2>
work as expected.
#3
in reply to:
↑ 2
@
13 years ago
It is both an anchor and a link, which is perfectly valid HTML. It behaves as intended in every browser I've ever tried it in. The point is that I want to have a table of contents at the top of my document which links to all of the sections, and I want each of the section headers if clicked, to take the user back to the table of contents.
According to http://www.w3.org/TR/html4/struct/links.html, "Authors may set the name and href attributes simultaneously in the same A instance."
TinyMCE is therefore clearly behaving incorrectly.
#4
@
13 years ago
The id
attribute can be used in place of name
for this purpose. As stated on the same page you link above:
When the
name
orid
attributes of theA
element are set, the element defines an anchor that may be the destination of other links.
So your example would become:
<h2><a id="foo" href="#bar">Foo</a></h2>
TinyMCE seems to handle this correctly.
Of course, this doesn't change the fact that it should probably behave in the same way with name
too.
#5
@
13 years ago
I believe TinyMCE is following the XHTML spec, the name attribute was replaced by id in xhtml and html5 IIRC.
#6
@
13 years ago
Looks like name
on a
elements is deprecated in XHTML (http://www.w3.org/TR/xhtml1/#C_8) and "obsolete but conforming" in HTML 5 (http://dev.w3.org/html5/spec/Overview.html#warnings-for-obsolete-but-conforming-features).
Reproduced on trunk, which is TinyMCE 3.4.8.