473,811 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<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.anchor s 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 2339
On Sat, 21 Aug 2004 13:28:23 -0600, Helge Moulding <hm*******@exci te.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*******@exci te.com> wrote in message
news:cg******** **@news.xmissio n.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**********@n ews.xmission.co m>,
the lovely and talented Helge Moulding
broadcast on comp.infosystem s.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">lin k 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.anchor s 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">lin k 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">lin k 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.anchor s 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.infosystem s.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

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

Similar topics

2
3237
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 writing one object in C# which will take the entire table tag contents and renders. Ie., we need to pass "<table>………… <thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
2
10572
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 type="text/javascript"> <!]> </script> <script type="text/javascript"
1
1650
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 provide values for clauses. I've also been able to call functions as above, as long as I don't use Container.DataItem to pass some value from the bound data to the function. If I do I get the
3
1732
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 data from the databinding to the loop that runs in a regular
1
2635
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 have that particular checkbox checked by default. I am not using checkboxlist because I want to EASILY save data to DB with a comma separated list which HTML gives you if all the checkboxes have the same name. <asp:datalist id=DataList1...
4
1568
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 to know why the <%# %> construct is necessary in locations where the other <%= %> does not do. It seems to me that there is no equivalent of the <%# %> construct in PHP, thus I thought I would post to clarify. Is this an ASP.NET specific...
5
1897
by: ad | last post by:
I find there are some tag like <%= %> and <%# > in my .aspx file. What is the diffreence between <%= %> and <%# %>
2
1489
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=<%# DataBinder.Eval(Container.DataItem,"id") %>',"blank","toolbar=no,width=520,height=550","resizable=0")> <IMG src="/ch/gallery/t<%# DataBinder.Eval(Container.DataItem, "id") %>.jpg"
3
2772
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 into a <xml> document but not sure which direction to take. Is there perhaps a starter document which uses sql server as the data source I can tap into.
3
3390
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, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10408
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3876
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.