473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

<A> Cannot be a Container for <A>?

I've tried the following:

<a name="foo" class="foostyle">Text in foo <a href="bar">link in foo</a>
and more text.</a>

I kinda thought that oughta work. But I found that foostyle is applied
only up to the link in foo. After that the style disappears. This
happens in both Mozilla and MSIE. Even adding contextual selectors to
the style doesn't help.

I played around with it using the Mozilla composer, and found that the
composer always repositions the </a> for the anchor to just before the
<a> for the link. To me that implies that an <A> cannot be a container
for an <A>. Is that correct? Or is there something else that I'm
overlooking?

Since I'm not likely going to change the implementation of 99% of the
browsers out there, it's more important that I figure out what to do
about this. What I'm doing is using a bit of script to switch styles
dynamically, to highlight a piece of text. The reason for doing it this
way stems from the fact that document.anchors is supported by both
Mozilla and MSIE. I'd like the text to include links, but then the
highlight stops at the link. What I've done for now is to code it as

<a name="foo" href="bar" class="foostyle">Text in foo with link in
foo and more text.</a>

which works, but has the unsatisfying side effect of turning the entire
section into a link, and limiting me to just one link per section.

http://www.rffutah.org/

is the page I'm talking about. The calendar on the right side is created
by the script, and when you move the mouse over the dates in September
(there are no hot dates in August), then the corresponding sections
above light up. I've removed the text underline, because an entire
section underlined looks unattractive. But if I knew of a way to get
around the "no <A> in <A>" limitation, I'd be a lot happier.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #1
23 2302
On Sat, 21 Aug 2004 13:28:23 -0600, Helge Moulding <hm*******@excite.com>
wrote:
I've tried the following:

<a name="foo" class="foostyle">Text in foo <a href="bar">link in foo</a>
and more text.</a>

I kinda thought that oughta work. But I found that foostyle is applied
only up to the link in foo. After that the style disappears. This
happens in both Mozilla and MSIE. Even adding contextual selectors to
the style doesn't help.

I played around with it using the Mozilla composer, and found that the
composer always repositions the </a> for the anchor to just before the
<a> for the link. To me that implies that an <A> cannot be a container
for an <A>. Is that correct? Or is there something else that I'm
overlooking?


http://www.w3.org/TR/html401/struct/links.html#h-12.2.2

"Links and anchors defined by the A element must not be nested; an A
element must not contain any other A elements."
Jul 23 '05 #2

"Helge Moulding" <hm*******@excite.com> wrote in message
news:cg**********@news.xmission.com...
I've tried the following:

<a name="foo" class="foostyle">Text in foo <a href="bar">link in foo</a>
and more text.</a>

I kinda thought that oughta work.


Looks like you thought wrong, huh?
http://www.w3.org/TR/html401/struct/links.html#h-12.2.2

-Karl
Jul 23 '05 #3
In our last episode,
<cg**********@news.xmission.com>,
the lovely and talented Helge Moulding
broadcast on comp.infosystems.www.authoring.html:
I've tried the following: <a name="foo" class="foostyle">Text in foo <a href="bar">link in foo</a>
and more text.</a> I kinda thought that oughta work. But I found that foostyle is applied
only up to the link in foo. After that the style disappears. This
happens in both Mozilla and MSIE. Even adding contextual selectors to
the style doesn't help.
You didn't say what DTD you are using, but I can't find one that allows
<a> in <a>. Also, I bet you mean href="#bar". You can have both name
and href attributes in the same <a>. This might, or might not, do
what you want to do:

<span class="foostyle">Text in foo <a name="foo" href="#bar">link in foo</a>
and more text.</span>

I played around with it using the Mozilla composer, and found that the
composer always repositions the </a> for the anchor to just before the
<a> for the link. To me that implies that an <A> cannot be a container
for an <A>. Is that correct?
Yes. You cannot nest <a>s.
Or is there something else that I'm
overlooking? Since I'm not likely going to change the implementation of 99% of the
browsers out there, it's more important that I figure out what to do
about this. What I'm doing is using a bit of script to switch styles
dynamically, to highlight a piece of text. The reason for doing it this
way stems from the fact that document.anchors is supported by both
Mozilla and MSIE. I'd like the text to include links, but then the
highlight stops at the link. What I've done for now is to code it as <a name="foo" href="bar" class="foostyle">Text in foo with link in
foo and more text.</a>
That will work too, if you really mean href="bar" instead of href="#bar".
which works, but has the unsatisfying side effect of turning the entire
section into a link, and limiting me to just one link per section. http://www.rffutah.org/ is the page I'm talking about. The calendar on the right side is created
by the script, and when you move the mouse over the dates in September
(there are no hot dates in August), then the corresponding sections
above light up. I've removed the text underline, because an entire
section underlined looks unattractive. But if I knew of a way to get
around the "no <A> in <A>" limitation, I'd be a lot happier.


--
Lars Eighner -finger for geek code- ei*****@io.com http://www.io.com/~eighner/
If it wasn't for muscle spasms, I wouldn't get any exercise at all.
Jul 23 '05 #4
Lars Eighner <ei*****@io.com> wrote:
<a name="foo" class="foostyle">Text in foo <a href="bar">link in
foo</a> and more text.</a>
I kinda thought that oughta work. But I found that foostyle is
applied only up to the link in foo. After that the style disappears.
This happens in both Mozilla and MSIE. Even adding contextual
selectors to the style doesn't help.


You didn't say what DTD you are using, but I can't find one that
allows <a> in <a>.


Well, there are several such DTDs: all XHTML DTDs. But why would that
matter? It's still against all HTML specifications - XML just is so
limited that the prohibition of <a> elements inside <a> elements cannot
be formally specified in a DTD (except by rewriting the DTD in a manner
that would make it _much_ longer and much more difficult to understand).
This might, or might
not, do what you want to do:

<span class="foostyle">Text in foo <a name="foo" href="#bar">link in
foo</a> and more text.</span>


That's may impression too. Or maybe some other element instead of <span>,
but the OP hasn't explained the need for the outer <a> element. And maybe
without the name attribute - I don't see what it would be needed for.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #5
Lars Eighner <ei*****@io.com> wrote:
<a name="foo" class="foostyle">Text in foo <a href="bar">link in
foo</a> and more text.</a>
I kinda thought that oughta work. But I found that foostyle is
applied only up to the link in foo. After that the style disappears.
This happens in both Mozilla and MSIE. Even adding contextual
selectors to the style doesn't help.


You didn't say what DTD you are using, but I can't find one that
allows <a> in <a>.


Well, there are several such DTDs: all XHTML DTDs. But why would that
matter? It's still against all HTML specifications - XML is just so
limited that the prohibition of <a> elements inside <a> elements cannot
be formally specified in a DTD (except by rewriting the DTD in a manner
that would make it _much_ longer and much more difficult to
understand).
This might, or might
not, do what you want to do:

<span class="foostyle">Text in foo <a name="foo" href="#bar">link in
foo</a> and more text.</span>


That's my impression too. Or maybe some other element instead of
<span>, but the OP hasn't explained the need for the outer <a> element.
And maybe without the name attribute - I don't see what it would be
needed for.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #6
Helge Moulding wrote:
I've tried the following:

<a name="foo" class="foostyle">Text in foo <a href="bar">link in foo</a>
and more text.</a>

I kinda thought that oughta work. But I found that foostyle is applied
only up to the link in foo. After that the style disappears. This
happens in both Mozilla and MSIE. Even adding contextual selectors to
the style doesn't help.

I played around with it using the Mozilla composer, and found that the
composer always repositions the </a> for the anchor to just before the
<a> for the link. To me that implies that an <A> cannot be a container
for an <A>. Is that correct? Or is there something else that I'm
overlooking?

Since I'm not likely going to change the implementation of 99% of the
browsers out there, it's more important that I figure out what to do
about this. What I'm doing is using a bit of script to switch styles
dynamically, to highlight a piece of text. The reason for doing it this
way stems from the fact that document.anchors is supported by both
Mozilla and MSIE. I'd like the text to include links, but then the
highlight stops at the link. What I've done for now is to code it as

<a name="foo" href="bar" class="foostyle">Text in foo with link in
foo and more text.</a>

which works, but has the unsatisfying side effect of turning the entire
section into a link, and limiting me to just one link per section.

http://www.rffutah.org/

is the page I'm talking about. The calendar on the right side is created
by the script, and when you move the mouse over the dates in September
(there are no hot dates in August), then the corresponding sections
above light up. I've removed the text underline, because an entire
section underlined looks unattractive. But if I knew of a way to get
around the "no <A> in <A>" limitation, I'd be a lot happier.


This should solve your problem: www.vladdy.net/Demos/IEPseudoClassesFix.html

And remember presentation comes after semantically meaninfull mark-up

--
Vladdy
http://www.klproductions.com
Jul 23 '05 #7
In our last episode,
<Xn*****************************@193.229.0.31>,
the lovely and talented Jukka K. Korpela
broadcast on comp.infosystems.www.authoring.html:
Lars Eighner <ei*****@io.com> wrote:
<a name="foo" class="foostyle">Text in foo <a href="bar">link in
foo</a> and more text.</a>

I kinda thought that oughta work. But I found that foostyle is
applied only up to the link in foo. After that the style disappears.
This happens in both Mozilla and MSIE. Even adding contextual
selectors to the style doesn't help.


You didn't say what DTD you are using, but I can't find one that
allows <a> in <a>.

Well, there are several such DTDs: all XHTML DTDs.
I have been wrong before but my copy of XHTML 1.0 Strict declares:

<!ELEMENT a %a.content>

and entity a.content does not include a.
But why would that
matter? It's still against all HTML specifications - XML just is so
limited that the prohibition of <a> elements inside <a> elements cannot
be formally specified in a DTD (except by rewriting the DTD in a manner
that would make it _much_ longer and much more difficult to understand).


I know nothing about XML, but it appears to me that at least one
XHTML DTD has managed to specify that <a> cannot include <a>.
--
Lars Eighner -finger for geek code- ei*****@io.com http://www.io.com/~eighner/
If it wasn't for muscle spasms, I wouldn't get any exercise at all.
Jul 23 '05 #8
Lars Eighner <ei*****@io.com> wrote:
I have been wrong before but my copy of XHTML 1.0 Strict declares:

<!ELEMENT a %a.content>

and entity a.content does not include a.


Well, we are both wrong. :-) Unlike I remembered, the DTD indeed forbids
an <a> element as a child (immediate subelement) of another <a> element.
But it does not forbid an <a> element inside <a>, since in a.content,
several elements may contain <a> elements and there's no exclusion
mechanism to forbid this. Thus, <a><a></a></a> triggers a syntax error,
but <a><span><a></a></span></a> does not.

(Cf. to http://www.w3.org/TR/xhtml1/#h-4.9 )

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #9
Neal wrote,
http://www.w3.org/TR/html401/struct/links.html#h-12.2.2
"Links and anchors defined by the A element must not be nested; an A
element must not contain any other A elements."


Thanks for the pointer. I suspected something like this was the case, since
both major browsers behave that way.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #10
Lars Eighner wrote,
<a name="foo" href="bar" class="foostyle">Text in foo with link in
foo and more text.</a>

That will work too, if you really mean href="bar" instead of href="#bar".


No, I mean href="bar". I tried to explain; I'll try a little harder. :-)

I have one place on the page where I have a mouseover effect:

<a href="#" onmouseover="hilight(1)" onmouseout="nohilight(1)">13</a>

The mouseover effect is not for this spot, but for somewhere else on the
page:

<a name="event1">August 13: Today is Friday the 13th!</a>

When you move the pointer over the first link, then the text in the
anchor gets highlighted. The reason for using the anchor tag is because
it is equally supported by both major browsers as an array at
document.anchors[].

My reason for asking here is that, as has now been pointed out by a
number of people who know the DTDs a lot better than I do, you can't
have an <a> inside an <a>. (In fact, I tried to cheat by wrapping the
inside <a> in a <span>, and at least Mozilla is wise to that. It turns
"<a>foo <span><a>bar</a></span> text</a>" into "<a>foo </a><span></span>
<a>bar</a> text".) So if I want to include a link in the text that gets
highlighted, I have to make the entire text the link.

I suppose if there were a way for me to find the text to highlight
that's as easy as document.anchors[], then my problem would be
solved. But that's a question for a JavaScript group. :-)
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #11
Jukka K. Korpela wrote
[...] the OP hasn't explained the need for the outer <a> element.


Because I need JavaScript to be able to find the element, and
document.anchors[] is an array of anchors that's supported by both
major browsers. This is where I go to a JavaScript group to ask if
there's some other array of elements that's equally well supported
by both major browsers.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #12
Vladdy wrote,
This should solve your problem: www.vladdy.net/Demos/IEPseudoClassesFix.html
Nope. Wrong problem, but it's good to know that this solution exists. :-)
And remember presentation comes after semantically meaninfull mark-up


Not sure I understand what that means. Do you mean I shouldn't use an
anchor tag to help me make the document pretty, because anchor tags are
meant to be used for something else? I suppose you're right, but that
doesn't help me solve this problem.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #13
On 23 Aug 2004 11:45:08 -0700, Helge Moulding <hm*******@excite.com> wrote:
Neal wrote,
http://www.w3.org/TR/html401/struct/links.html#h-12.2.2
"Links and anchors defined by the A element must not be nested; an A
element must not contain any other A elements."


Thanks for the pointer. I suspected something like this was the case,
since
both major browsers behave that way.

Heh - IE and NN both doing something the same is still no guarantee it's
based on the specs.
Jul 23 '05 #14
Helge Moulding wrote:
I suspected something like this was the case, since
both major browsers behave that way.


There's more to www user agents than NN and MSIE, you know.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #15
Helge Moulding wrote:
I have one place on the page where I have a mouseover effect:

<a href="#" onmouseover="hilight(1)" onmouseout="nohilight(1)">13</a>
href="#" is a bogus construction, and should be avoided at all costs.
When you move the pointer over the first link, then the text in the
anchor gets highlighted. The reason for using the anchor tag is
because it is equally supported by both major browsers as an array at
document.anchors[].
You can set onmouseover events for other elements. What sort of browser
support is required?
I suppose if there were a way for me to find the text to highlight
that's as easy as document.anchors[], then my problem would be
solved. But that's a question for a JavaScript group. :-)


True. Perhaps you should ask there? Or, before asking, Google for
getElementById and see if that will do what you want.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #16
Brian said the following on 23/08/2004 21:57:
href="#" is a bogus construction, and should be avoided at all costs.


I've read some tutorials which use href="#" in an unordened list and
style it up later with CSS and/or JavaScript. Two of them are:

http://www.alistapart.com/articles/horizdropdowns/
http://www.dhtmlcentral.com/tutorial...p?page=4&id=14

I'm think that they used it in the 2nd level of <li>'s so that in the
examples one can click on those links and they should be replaced with
valid targets, but to what should it be changed in the 1st level of
<li>'s then?

--
Regards
Harrie
Jul 23 '05 #17
Harrie wrote:
Brian said the following on 23/08/2004 21:57:
href="#" is a bogus construction, and should be avoided at all costs.


http://www.alistapart.com/articles/horizdropdowns/

I'm think that they used it in the 2nd level of <li>'s so that in the
examples one can click on those links and they should be replaced with
valid targets, but to what should it be changed in the 1st level of
<li>'s then?


A real page - I suggest an index page for the associated submenu items.
This ensures your visitors can access those pages even if they can't get
to the links using the menu, as will likely happen with keyboard
navigation and other mouse-challenged situations.

However, DHTML menus generally suck, so I wouldn't recommend using one
in the first place.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Jul 23 '05 #18
Helge Moulding wrote:
Thanks for the pointer. I suspected something like this was the case,
since both major browsers behave that way.


Lynx *and* Konqueror, you mean?

There are dozens, if not hundreds, of browsers out there.

--
Shawn K. Quinn
Jul 23 '05 #19
Shawn K. Quinn wrote:
Helge Moulding wrote:

both major browsers behave that way.

Lynx *and* Konqueror, you mean?

(sigh) Those are loser browsers. *Obviously*, he was talking
about W3M and Amaya. Sheesh.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #20
Brian wrote,
Google for getElementById and see if that will do what you want.


Thanks for the hint. Works like a charm.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #21
Brian wrote,
Google for getElementById and see if that will do what you want.


Thanks for the hint. Works like a charm.
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #22
Brian wrote,
Shawn K. Quinn wrote:
Helge Moulding wrote:
both major browsers behave that way.

Lynx *and* Konqueror, you mean?

(sigh) Those are loser browsers. *Obviously*, he was talking
about W3M and Amaya. Sheesh.


*THAT*'s the ones!
--
Helge Moulding
mailto:hm*******@excite.com Just another guy
http://hmoulding.cjb.net/ with a weird name
Jul 23 '05 #23
kchayka said the following on 24/08/2004 00:32:
Harrie wrote:
Brian said the following on 23/08/2004 21:57:
href="#" is a bogus construction, and should be avoided at all costs.
http://www.alistapart.com/articles/horizdropdowns/

I'm think that they used it in the 2nd level of <li>'s so that in the
examples one can click on those links and they should be replaced with
valid targets, but to what should it be changed in the 1st level of
<li>'s then?


A real page - I suggest an index page for the associated submenu items.


Hadn't thought about that. It's some extra work, but it sounds like a
good idea.
This ensures your visitors can access those pages even if they can't get
to the links using the menu, as will likely happen with keyboard
navigation and other mouse-challenged situations.
I was thinking about keyboard navigation for all (sub)menu items, but
I'm new to that and still learning. I'm also still reading the WAI
documentation to learn about accessibility issues.
However, DHTML menus generally suck, so I wouldn't recommend using one
in the first place.


I'm slowly comming to that solution myself. I liked the idea of the
JavaScript styled-up menu, because it decrades to a simple (unordend)
list whitout JavaScript. But since JavaScript is not 100% compatible
over different browsers and I don't like the idea of browser detection
and different codings, I thought I'd give the CSS menu a chance.

--
Harrie
Jul 23 '05 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
1
by: fig000 | last post by:
Hi, I have some code written into the html in a dot.net form: <%if test(Container.DataItem("user_id")) =2%> I've been able to use container.dataitem in these <%%> pairs as an expression to...
3
by: z. f. | last post by:
Hi, i'm using code in my aspx page. i have data binding where i use <%# Container.DataItem("DateStart") %> i also use code that makes a loop inside a regular <% %> block how can i pass...
1
by: Ed West | last post by:
Am getting this error with the following code, particularly this line: <%# Check(DataBinder.Eval(Container.DataItem, "broker_id"))%> I am creating checkboxes and the Check function checks to...
4
by: Neil Zanella | last post by:
Hello, I would like to know what the difference is among the constructs <%= %> for evaluating an expression and displaying the evaluated result on the page and <%# %>. In particular I would like...
5
by: ad | last post by:
I find there are some tag like <%= %> and <%# > in my .aspx file. What is the diffreence between <%= %> and <%# %>
2
by: Aahz | last post by:
I know this problem has been discussed before but still cannot work it out, here is my code: <span class="popup" onClick = javascript:window.open('fullimage.aspx?id=<%#...
3
by: | last post by:
I have been researching articles on google on how to create a simple RSS feed that sucks <title><blurb><link><date> out of a sql server 2000 database via an aspx page. I know it has to be pushed...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.