Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: HTML tags in perl CGI scripts

by mojobozo (Monk)
on Nov 14, 2002 at 13:01 UTC ( #212827=note: print w/ replies, xml ) Need Help??


in reply to HTML tags in perl CGI scripts

One thing I have found in HTML, if you want to do it that way you can and the QUOTES DON'T MATTER. I've been doing this a lot recently with ASP pages and have started leaving the quotes out entirely and have had no problems. TMTOWTDI!
_____________________________________________________
mojobozo
word (wrd)
interj. Slang. Used to express approval or an affirmative response to
something. Sometimes used with up. Source


Comment on Re: HTML tags in perl CGI scripts
Re: Re: HTML tags in perl CGI scripts
by LTjake (Prior) on Nov 14, 2002 at 13:25 UTC
    It is true that, in general, the parsers won't care if your values are quoted or not. But, I'm going to have to recommend against this.

    If you want to be forward thinking in the least, you should try hard to conform to W3C standards.
    By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ". (source)


    --
    Rock is dead. Long live paper and scissors!
      Sorry, I never read it.
      _____________________________________________________
      mojobozo
      word (wrd)
      interj. Slang. Used to express approval or an affirmative response to
      something. Sometimes used with up. Source
      HTML (which is supposed to be an SGML application) doesn't require quotation marks around attribute values. The next paragraph of the specification says:

      In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.

      It also recommends including the quotes. For one thing, XML requires quotation marks and always including quotes will make code easier to transition to XHTML.

      It is dangerous to leave out the quotes when interpolating a variable. Someone in the future might try to put a space (or a quote) in the variable. Browsers try to deal with broken markup but it is wise not to abuse the browser. Anyone leaving out the quotes because they haven't had a problem yet is going to be scratching their head in the future wondering why their HTML isn't working on some other browser or made an unrelated change in the code.

Re: Re: HTML tags in perl CGI scripts
by BUU (Prior) on Nov 14, 2002 at 13:35 UTC
    The quotes only matter if you use whitespace or possibly [^a-zA-Z0-9] type chars, such as '=', quotes and so forth. Most of the html parsers i've seen treat whitespace as the attribute delimiter for html tags. Example: <tag attr=thisworks attr2=this does not work>, although some browsers my parse that in different ways.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://212827]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-10-01 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (9 votes), past polls