473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XHTML Validation fails with nested block elements.

I've got my page working just as I wanted it - but when I came to
validate the XHTML, using W3c's validator it failed. Essentially as
far as I can see it the problem is this:

1: <div>
2: <a href="somelink. htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
7: </a>
8: </div>

At line 3, it fails because it says a block level tag (I assume the
<div>) is nexted in an inline tag (which I assume is the <a> tag).

In the stylesheet I have the a tag set as display:block;

So my question is, if the <a> tag is set to be 'block' by the CSS, does
this technically mean that the XHTML is valid, as the <a> tag is no
longer inline in this context?

Jul 23 '05 #1
12 2546


se*****@hotmail .com wrote:
but when I came to
validate the XHTML, using W3c's validator it failed. 1: <div>
2: <a href="somelink. htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
7: </a>
8: </div>

At line 3, it fails because it says a block level tag (I assume the
<div>) is nexted in an inline tag (which I assume is the <a> tag).
Yes,.
In the stylesheet I have the a tag set as display:block;

So my question is, if the <a> tag is set to be 'block' by the CSS, does
this technically mean that the XHTML is valid, as the <a> tag is no
longer inline in this context?


No, a stylesheet doesn't matter, the DTD clearly says which elements are
allowed inside of an <a> element and against the DTD the XHTML is not
valid, whatever stylesheet you use.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
se*****@hotmail .com wrote:
I've got my page working just as I wanted it - but when I came to
validate the XHTML, using W3c's validator it failed. Essentially as
far as I can see it the problem is this:

1: <div>
2: <a href="somelink. htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
7: </a>
8: </div>

At line 3, it fails because it says a block level tag (I assume the
<div>) is nexted in an inline tag (which I assume is the <a> tag).

In the stylesheet I have the a tag set as display:block;

So my question is, if the <a> tag is set to be 'block' by the CSS, does
this technically mean that the XHTML is valid, as the <a> tag is no
longer inline in this context?


No. There is only one flavour of valid. Provide an url to the page if
you want suggestions on how to change it.

--
Spartanicus
Jul 23 '05 #3
se*****@hotmail .com wrote:
I've got my page working just as I wanted it - but when I came to
validate the XHTML, using W3c's validator it failed. Essentially as
far as I can see it the problem is this:

1: <div>
2: <a href="somelink. htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
7: </a>
8: </div>

At line 3, it fails because it says a block level tag (I assume the
<div>) is nexted in an inline tag (which I assume is the <a> tag).
Yes. (once we correct tag -> element)
In the stylesheet I have the a tag set as display:block;
So what? That's just how the <a> element is displayed not what it is.
So my question is, if the <a> tag is set to be 'block' by the CSS, does
this technically mean that the XHTML is valid, as the <a> tag is no
longer inline in this context?


No. <a> is always an inline element in (x)html regardless of how it is
displayed.

Steve

Jul 23 '05 #4
Thanks - the thing is not live on the internet yet, however I have
constructed a 'test' page which demonstrates the same effect:

http://www.seajays.org.uk/test_xhtml.htm

The rollover effect of the box turning grey is what I want - and it
*looks* fine onscreen. It's just that because I had to use <div> to
push each containing box down so that it would carry on past the image,
the whole lot ends up inside the anchor tag, and that won't validate.
Any suggestions gratefully received.

Cheers,
Colin.

Jul 23 '05 #5
"se*****@hotmai l.com" <se*****@hotmai l.com> wrote:
Thanks
Please quote a bit of what it is you are replying to, snip it down to
the minimum, and put your reply beneath it.
- the thing is not live on the internet yet, however I have
constructed a 'test' page which demonstrates the same effect:

http://www.seajays.org.uk/test_xhtml.htm


I'd would position the images to the left on the same line as the header
text, and I'd omit hyper linking the text beneath the header. If you do
that then the change is simple, just insert the image in the header and
place the hyper link around the image and header text.

You can keep the existing method, but it would require at least 2 links
pointing at the same page, this is not good UI design.

A compromise is to omit the text beneath the header linking, but keep
the image above the header, you can do that by including the image in
the header and follow it with a <br>.

--
Spartanicus
Jul 23 '05 #6
Spartanicus wrote:
"se*****@hotmai l.com" <se*****@hotmai l.com> wrote:
Thanks
Please quote a bit of what it is you are replying to, snip it down to
the minimum, and put your reply beneath it.


Yeah Sorry - not yet used to the new Google Groups interface...
- the thing is not live on the internet yet, however I have
constructed a 'test' page which demonstrates the same effect:

http://www.seajays.org.uk/test_xhtml.htm


I'd would position the images to the left on the same line as the

header text, and I'd omit hyper linking the text beneath the header. If you do that then the change is simple, just insert the image in the header and place the hyper link around the image and header text.


OK thanks,

Have tried this (see http://www.seajays.org.uk/test_xhtml2.htm ) - and
the page now validates.

Unfortunately it no longer produces the effect that I wanted. The
'grey' highlight when you hover over is no longer in the entire box,
just over the title. :(

Also on a high resolution screen, if the browser is maximised, the
image starts to poke out of the bottom of the grey box. I had found a
solution to this in the 'expander' div, however we're then back to the
problem of including the div in the anchor element. Is there a way to
ensure that the containing boxes will be the right size to hold the
image, even though the image is floated left?

Another issue is, if the window is resized smaller, the text starts to
wrap around the bottom of the image, instead of keeping itself in line
to the right (as in the first example).

Am I approaching this in the wrong way? Should I just be looking at
using javascript mouseovers to achieve the effect, in order to be able
to write valid XHTML or is there some other method I could try in CSS?
Cheers,
Colin.

Jul 23 '05 #7
"se*****@hotmai l.com" <se*****@hotmai l.com> wrote:
Have tried this (see http://www.seajays.org.uk/test_xhtml2.htm ) - and
the page now validates.

Unfortunatel y it no longer produces the effect that I wanted. The
'grey' highlight when you hover over is no longer in the entire box,
just over the title. :(
I see that you've also edited the original example, I didn't notice or
paid any attention to any hover functionality when I looked at the
original example.

[Checks in IE]

Aha, it has a hover effect in IE. Note that very few of the regulars
here use IE as their default browser, so if you upload something that
only works in IE you need to say so (and then duck :-).
Also on a high resolution screen, if the browser is maximised, the
image starts to poke out of the bottom of the grey box.
Yep, floats are removed from the flow, however there should be no need
to resort to floating the image, img elements are inline and can thus be
used as is, you can specify alignment of adjacent text with the css
vertical-align property.
Am I approaching this in the wrong way? Should I just be looking at
using javascript mouseovers to achieve the effect, in order to be able
to write valid XHTML or is there some other method I could try in CSS?


In good browsers the :hover pseudo class can be applied not just on
anchors, but on any element. Alas IE doesn't want to play that game.

I'm can't recall what the best approach is to circumvent that limitation
in IE, others will jump in I'm sure.

--
Spartanicus
Jul 23 '05 #8
On 10 Jan 2005 04:38:41 -0800, se*****@hotmail .com wrote:

1: <div>
2: <a href="somelink. htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
7: </a>
8: </div>


Try this

<div>
<a href="somelink. htm">
<span class="span-made-to-look-like-div" >
<span class="span-made-to-look-like-h2" >Title</span>
Some text
</span>
</a>
</div>

You can probably work out the CSS yourself.
Validity according to the DTD is just that - according to the DTD. It
takes no account of anything you do in the CSS. Besides which, the
DTD works with with a set of elements called "the set of block level
elements", it doesn't even imply any connection with the same notion
of "blockness" as a CSS display:block;
Jul 23 '05 #9

"Andy Dingley" <di*****@codesm iths.com> wrote in message
news:6m******** *************** *********@4ax.c om...
Try this

<div>
<a href="somelink. htm">
<span class="span-made-to-look-like-div" >
<span class="span-made-to-look-like-h2" >Title</span>
No! A heading should be marked up as a heading. This isn't a correct
solution to his problem.
Some text
</span>
</a>
</div>


Jul 23 '05 #10

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

Similar topics

59
4780
by: Philipp Lenssen | last post by:
I've tested some of the new Nokia 6600 functionality. It ships with WAP2 and XHTML Support (it says). What it does is check the Doctype -- if it's not the XHTML Mobile Profile Doctype, but a XHTML1.0 Strict one, the media-handheld CSS is _ignored_. Only with the Nokia Doctype, the CSS is used. I find this really annoying as it goes against the whole idea of media-independent XHTML Strict along with stylesheets. On the good side, WML...
41
1248
by: CMAR | last post by:
What are the pluses and minuses of constructing and validating between XHTML Transitional vs. HTLM 4.01 Strict Thanks, CMA
32
2949
by: Cornel Bicutzi | last post by:
Hello, What is the difference between HTML and XHTML... Thanks, ------------------------------------------------------------------------ IT Interview Questions : http://www.geekinterview.comIT Tutorials and Articles : http://www.geekarticles.com
6
15419
by: deko | last post by:
How do I construct an XHTML-compliant nested unordered list? This displays correctly (both FF and IE): <ul> <li>list item</li> <li>list item</li> <li>list item</li> <ul> <li>nested list item</li>
3
1762
by: dantohester | last post by:
Hi there, I have the following situation: I want to create an XML document that contains 2 parts: a) a XHTML part (it can be either version 1.0 or 1.1 ) b) a non XHTML part that contains some information about the first part - like the location of that content or some other info on different constituents of the first part The elements of the second part are defined by an XML schema.
21
4609
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML validator does not tolerate XML-style empty tags. It seems serving XHTML to the browser is of no advantage and can cause serious problems if the browser does not understand the difference. This raises the question of downgrading XHTML to HTML. I could...
7
3073
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has the following? <xsl:output method="xml"
2
2298
by: Henry Stock | last post by:
I can understand what these error messages are telling me, but I guess I am not sure how to address them all. The bold tag could be handled in a class attribute, but I need a <br/tag inside the form for formatting and the input fields are necessary for getting data. Error 3 Validation (XHTML 1.1): Element 'br' cannot be nested within element
37
3678
by: Prisoner at War | last post by:
Actually, it doesn't have to be a blockquote...but I'm at my wits' end: I want to make bold several lines of text which have a pair of <br /tags between them...seems like the <b></bdo not "carry over" when there are <br /tags involved...??? I've tried using <p style="font-weight: bold;"></p>, I've tried <blockquote></blockquote>...I just can't figure how I'm supposed to get the <b></btags to work for all the lines! Surely there must be...
0
9619
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
10261
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
10103
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
10038
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
9911
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
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2850
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.