Hyperlinks and whitespace

For technical support for all editions of CSE HTML Validator. Includes bug reports.

Hyperlinks and whitespace

Postby ajtruckle » Sat Feb 27, 2010 2:28 pm

Hello

I have some HTML:

Code: Select all
<a href="default.php" title="Silcox Son &amp; Wicks home page">
   <img alt="Silcox logo" height="50" src="./image/silcox_logo_trans2.gif" width="389" class="SilcoxLogo" /></a>

After running it through the validator it makes this comment:

The text content of the "a" element begins and ends with whitespace. This may not be wanted.

I appreciate that it says "may not be wanted" but what I am asking here is if my coding is actually wrong or not?

When would this become a valid cause for concern?

Thank you.

Andrew
ajtruckle
Rank II - Novice
Rank II - Novice
 
Posts: 41
Joined: Sat Feb 27, 2010 2:24 pm

Re: Hyperlinks and whitespace

Postby Albert Wiersch » Sat Feb 27, 2010 2:59 pm

Hi Andrew,

It's not technically wrong... it is just that it is often unusual and unwanted to have such spaces, but sometimes they may be wanted.

You can change that message to a different type or disable it all together (if you don't care about this issue) by right-clicking on it in CSE HTML Validator's editor.

I will change the message to make it more clear that it is technically allowed.
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: Hyperlinks and whitespace

Postby ajtruckle » Sat Feb 27, 2010 3:08 pm

Hi

Being a programmer for many years I have always tended to keep code within the screen area so that I can see what is going on without having to scroll horizontally. I guess that the textual form of a program also conveys clarity as to readability.

So in some instances I applied this to the html syntax and added in newline characters. My concern here is that to avoid the message in this context I would need everything on one line. If it is a textual link then this is probably more than acceptable because the link wording is not long anyway. But when the link context is an image, then from my perspective it adds clarity to kind of split the html syntax up a bit.

Interestingly, I just used Expression Web 3 to insert an image and then allocate it as a hyperlink. EW3 generates standards compliant code and this is the result:

Code: Select all
<p><a href="http://www.microsoft.com">
<img alt="Test" class="style1" height="113" src="file:///F:/My%20Web%20Sites/Silcox/image/thumb/00006_small.jpg" width="170" /></a></p>

I thought it interesting that in inserted a newline itself. Thus many of these warnings are probably EW3 derived anyway. I just wonder if we could have some kind of option to allow this kind of condition when the link is an image?

Andrew
ajtruckle
Rank II - Novice
Rank II - Novice
 
Posts: 41
Joined: Sat Feb 27, 2010 2:24 pm

Re: Hyperlinks and whitespace

Postby Albert Wiersch » Sat Feb 27, 2010 3:37 pm

ajtruckle wrote:
Code: Select all
<p><a href="http://www.microsoft.com">
<img alt="Test" class="style1" height="113" src="file:///F:/My%20Web%20Sites/Silcox/image/thumb/00006_small.jpg" width="170" /></a></p>

I thought it interesting that in inserted a newline itself. Thus many of these warnings are probably EW3 derived anyway. I just wonder if we could have some kind of option to allow this kind of condition when the link is an image?


Hi Andrew,

I just tried that piece of HTML in CSE HTML Validator and it didn't generate the whitespace message.

If you want to break lines, you could do it between attributes in a tag. Line breaking outside of tags results in the line break being interpreted as whitespace.

Example of breaking between attributes:

Code: Select all
<p><a href="http://www.microsoft.com"><img alt="Test" class="style1" height="113"
src="file:///F:/My%20Web%20Sites/Silcox/image/thumb/00006_small.jpg" width="170" /></a></p>
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: Hyperlinks and whitespace

Postby ajtruckle » Sat Feb 27, 2010 3:48 pm

I see, that makes sense. But then I am confused. The validator is warning for this file:

http://www.silcox.co.uk/new_site/contact-us.php

Line 174 character 1.

The only thing I can see is the tabbed character at the start of each line. This is the only whitespace. Is that wrong? That is all I can think of.

Andrew
ajtruckle
Rank II - Novice
Rank II - Novice
 
Posts: 41
Joined: Sat Feb 27, 2010 2:24 pm

Re: Hyperlinks and whitespace

Postby Albert Wiersch » Sat Feb 27, 2010 4:00 pm

Hi Andrew,

Again, it's not technically wrong, but there does seem to be an inconsistency in the validator message. I will look into that next week.

Though most people would probably not want the linked whitespace before the image, that's why that message is generated.
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: Hyperlinks and whitespace

Postby Albert Wiersch » Mon Mar 01, 2010 3:20 pm

Albert Wiersch wrote:... there does seem to be an inconsistency in the validator message ...


I believe I've addressed the inconsistency for the next BETA. Previously, in some cases, a line break would not be considered whitespace so this message would not display. This should now be fixed.
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: Hyperlinks and whitespace

Postby ajtruckle » Mon Mar 01, 2010 3:33 pm

Alright ... thanks for that.

Andrew
ajtruckle
Rank II - Novice
Rank II - Novice
 
Posts: 41
Joined: Sat Feb 27, 2010 2:24 pm


Return to CSE Tech Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron