473,624 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to validate HTML with variables in link?

I use variables in some links on my page. I need to send these variables so
I can change the color of the links in the navbar when the user is on that
page. If you click around on the site you will see the links in the navbar
change:

http://www.clearpointsystems.com/

When I try to validate the page at http://validator.w3.org/ I get the
following error:

Line 120, column 42: an attribute value must be a literal unless it contains
only name characters

<p><span class=blulink>< a href=index.php? 'home'>Home Page</a></span></p>

You have used a character that is not considered a "name character" in an
attribute value. Which characters are considered "name characters" varies
between the different document types, but a good rule of thumb is that
unless the value contains only lower or upper case letters in the range a-z
you must put quotation marks around the value. In fact, unless you have
extreme file size requirements it is a very very good idea to always put
quote marks around your attribute values. It is never wrong to do so, and
very often it is absolutely necessary.

If I try to put quotes around the variables, they no longer work:

<p><span class=blulink>< a href=index.php? "home">Home Page</a></span></p>
[does not work]

How can I use these variables and still have valid HTML code?

Thanks in advance.
Jul 20 '05 #1
2 5905
DU
deko wrote:
I use variables in some links on my page. I need to send these variables so
I can change the color of the links in the navbar when the user is on that
page. If you click around on the site you will see the links in the navbar
change:

http://www.clearpointsystems.com/

When I try to validate the page at http://validator.w3.org/ I get the
following error:

Line 120, column 42: an attribute value must be a literal unless it contains
only name characters

<p><span class=blulink>< a href=index.php? 'home'>Home Page</a></span></p>

You have used a character that is not considered a "name character" in an
attribute value. Which characters are considered "name characters" varies
between the different document types, but a good rule of thumb is that
unless the value contains only lower or upper case letters in the range a-z
you must put quotation marks around the value. In fact, unless you have
extreme file size requirements it is a very very good idea to always put
quote marks around your attribute values. It is never wrong to do so, and
very often it is absolutely necessary.

If I try to put quotes around the variables, they no longer work:

<p><span class=blulink>< a href=index.php? "home">Home Page</a></span></p>
[does not work]

How can I use these variables and still have valid HTML code?

Thanks in advance.


The validation error message included what to do:
"a good rule of thumb is that unless the value contains only lower or
upper case letters in the range a-z you must put quotation marks around
the value. In fact, unless you have extreme file size requirements it is
a very very good idea to always put quote marks around your attribute
values."

So,

<p><span class="blulink" ><a href="index.php ?home">Home Page</a></span></p>

will validate and since you already had

a:link { color:#333399 }
a:visited { color:#333399 }
a:active { color:#333399 }
a:hover { color:#333399 }

a:link img { border:0px }
a:visited img { border:0px }
a:hover img { border:0px }
a:active img { border:0px }

.blulink a:link { color:#333399 }
.blulink a:visited { color:#333399 }
.blulink a:hover { color:#333399 }
.blulink a:active { color:#333399 }

in your stylesheet then you don't need at all to have
..blulink a:link { color:#333399 }
etc

The simple
<p><a href="index.php ?home">Home Page</a></p>
will do exactly what you want and will validate without any extra bloat
code.

Your stylesheet indicates you don't know how to use the inheritance
feature of CSS.

DU
Jul 20 '05 #2
<a href="index.php ?home">

so *that's* what I need to put quotes around...

Thanks for the help.
Jul 20 '05 #3

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

Similar topics

6
2322
by: deko | last post by:
I have a basic Feedback form - I want to prevent blank entries. The problem with the below code is that the form still Posts if the 'message' field is blank. The form will not post if the 'email_address' field is blank, however. Why doesn't it catch empty 'message' field? <form method="POST" action= "<? $message = $_POST; $email_address = $_POST; if ( empty($message) || empty($email_address) )
0
3160
by: Ray Tayek | last post by:
hi, fooling around with xmlspy (which seems pretty broken when *doing* xslt's). trying to validate in java using code from http://cermics.enpc.fr/doc/java/j2eetutorial-1.4/doc/JAXPSAX13.html (click on the Echo10.java link). i get an error saying that a doctype decl is required (see below). i get the same error whether or not i turn on name space awareness. spy says this file is well formed and valid. and my java code that transforms it...
5
5338
by: Kit | last post by:
Hi there, I am recoding a website, and I want to add a generic footer to each page, using an included file with PHP snippets. Part of that footer would be a link to validate the page using the W3C's validation service. The code currently looks like this: <code> <a href="http://validator.w3.org/check?uri=<?php echo "http://www.athenatest.org" . $PHP_SELF; ?>" >
7
16237
by: Ali-R | last post by:
Hi all, I am getting a CSV file like this from our client: "C1","2","12344","Mr","John","Chan","05/07/1976"......... I need to validate **each filed value** against a set of rules ,for instance for "05/07/1976" ,I need to make sure that it's in the right format ,It's not later than today and lots of other rules ,Is there somebody who can help me how to that?Can I map it to some sort of xml schema or something?
5
1859
by: Jim | last post by:
Can someone PLEASE tell me where I'm going wrong. I've stared at this page for 2 hours and still can't get it to validate on http://validator.w3.org/check. Page URL : http://www.coffeemachine.com.au Offending Header section: ============================= <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
26
25601
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any idea? Thanks you very much
1
3987
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
4
1746
by: thupham | last post by:
I have 2 page: index.aspx next.aspx and the code in javascript to validate Email: function fnEmail() { if(checkEmail(form1.txtEmail.value)== false) { alert("Email is not valid!"); form1.txtEmail.focus();
0
569
by: Lars Eighner | last post by:
In our last episode, <004f629c$0$10265$c3e8da3@news.astraweb.com>, the lovely and talented mark4asp broadcast on comp.infosystems.www.authoring.html: I have not done this, not even on TV.
0
8251
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
8182
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
8688
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
8494
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
7178
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
6115
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
4085
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...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.