Skip to main content
Inspiring
June 27, 2016
Answered

missing a few html link basics

  • June 27, 2016
  • 1 reply
  • 857 views

Hi all,

I seem to be missing a few html link basics. What is the significance of:

starting slash...?

<form action="/mypage.php" method="POST">  like:

I know these can redirect:

dig down..

/myfolder/mypage.php

and up

../myfolder/mypage.php

but now I am seeing a starting slash and a page ???

/mypage.php

or

./mypage.php

instead of just = mypage.php

Q: why use starting ./ or / instead of just the page?

MORE...

and while I am at it... I always use closing php tag like:

<?php

stuff...

?>

... but now I am hearing if there is only php on the page - then it's best to *NOT* use a closing tag?

Q: Why is that?

    This topic has been closed for replies.
    Correct answer Jon Fritz

    The starting slash means "site root relative" which tells the browser to add the site root before the link, so...

    /somelink.html

    ...becomes...

    h t t p ://www.domain.com/somelink.html (spaces added to http keep the forum from turning it into a link)

    ...automatically at the browser level.

    Not sure about the php thing, always heard that as you "can" leave it out.

    1 reply

    Jon Fritz
    Community Expert
    Jon FritzCommunity ExpertCorrect answer
    Community Expert
    June 27, 2016

    The starting slash means "site root relative" which tells the browser to add the site root before the link, so...

    /somelink.html

    ...becomes...

    h t t p ://www.domain.com/somelink.html (spaces added to http keep the forum from turning it into a link)

    ...automatically at the browser level.

    Not sure about the php thing, always heard that as you "can" leave it out.

    revdaveAuthor
    Inspiring
    June 27, 2016

    Great - thanks for the help!

    so now I get /somelink.html

    what about with starting period = ./somelink.html ?

    David_Powers
    Inspiring
    June 27, 2016

    That means somelink.html is in the same folder (directory).