href confusion

  • Thread starter Thread starter Nak
  • Start date Start date
N

Nak

Hi there,

I know this isn't 100% relevant to ASP.NET but I'm hoping that someone
can shed some light on href's in HTML code.

Consider the following,

http://www.spoon.com/dir/page.html

I'm trying to work out the relationship between href's on the above page
and the pages own URI, for example, am I right in saying the following is
correct,

"/dir2/page.html" < Would become
http://www.spoon.com/dir2/page.html
"dir3/page.html" < Would become
http://www.spoon.com/dir2/dir3/page.html
"../page4.html" < Would become
http://www.spoon.com/page4.html

The reason I ask is that I am making an HTML href parser and this has
recently caused me much confusion. Also, are speech marks actually needed?
Because I've analyzed a few pages lately that haven't had any, for example

href="http://www.spoon.com/none/error.html"

and

href=http://www.spoon.com/none/error.html Correct ?

Thanks loads in advance for any help and sorry if this seems irrelivant
to ASP.NET but I was convinced that you guys would know this one.

Nick.
 
Nak said:
Consider the following,

http://www.spoon.com/dir/page.html

I'm trying to work out the relationship between href's on the above page
and the pages own URI, for example, am I right in saying the following is
correct,

"/dir2/page.html" < Would become
http://www.spoon.com/dir2/page.html
"dir3/page.html" < Would become
http://www.spoon.com/dir2/dir3/page.html
"../page4.html" < Would become
http://www.spoon.com/page4.html

Your understanding is correct.

XHTML requires that there be quotes around element attributes. I
believe HTML says there should be quotes there, but many browsers aren't
picky about it. Good HTML authors always use quoted attributes.

hth

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Answers are inline

Nak said:
Hi there,

I know this isn't 100% relevant to ASP.NET but I'm hoping that someone
can shed some light on href's in HTML code.

Consider the following,

http://www.spoon.com/dir/page.html

I'm trying to work out the relationship between href's on the above page
and the pages own URI, for example, am I right in saying the following is
correct,

"/dir2/page.html" < Would become
http://www.spoon.com/dir2/page.html
"dir3/page.html" < Would become
http://www.spoon.com/dir2/dir3/page.html
"../page4.html" < Would become
http://www.spoon.com/page4.html
Yes this is correct.

The reason I ask is that I am making an HTML href parser and this has
recently caused me much confusion. Also, are speech marks actually needed?
Because I've analyzed a few pages lately that haven't had any, for example

href="http://www.spoon.com/none/error.html"

and

href=http://www.spoon.com/none/error.html Correct ?
Read this article.....
http://ferruh.mavituna.com/article/?569
 
Hi Scott,
Your understanding is correct.

Excellent, thanks!
XHTML requires that there be quotes around element attributes. I
believe HTML says there should be quotes there, but many browsers aren't
picky about it. Good HTML authors always use quoted attributes.

That's a shame, I hate it when the standards get dropped, a bit like 3rd
party msstyles files, parsing those is a complete nightmare!

Nick.
 
Back
Top