Page 57 - DCAP202_Fundamentals of Web Programming
P. 57

Fundamentals of Web Programming




                    Notes          5.3.1 Links

                                   Links are defined with the <a> tag.
                                   Let’s create a link to the page defined in the file “anand.html”: This link to
                                     <a  href=”Example1.html”>upendra’s  homepage</a>.
                                   The text between the <a> and the </a> is used as the caption for the link. It is common for the
                                   caption to be in blue underlined text. It is by the way a good idea to not have any blank spaces
                                   in the names of your HTML files, as this might create problems with some web servers. You can
                                   use an underscore, “_”, to separate words in your file names.

                                   To link to a page on another web site you need to give the full web address (the URL). For
                                   instance, to link to “Google” you need to write:
                                   A link to <a href=”http://www.google.com”>Google</a>.

                                   If you want the user’s browser to open a new window for the linked page, (that way the user
                                   finds back to your page as soon as he or she closes the new window), use the attribute target:
                                   A link to <a href=http://www.google.com target=’_blank’>Google</a>.

                                   5.3.2 External Document References


                                   Syntax
                                   <A  HREF  =  “fname.htm”>  Hyperlink  CONTENT  </A>


                                          Example: <A HREF =”mypage.htm”> Visit to my main page </A>
                                   Here Visit to my main  page will be the name of link which will link to another document,
                                   mypage.html, Which is present in the current working directory. If the file is not present in the
                                   current directory, a relative or absolute path can be specified.
                                   To move to a specific location on a Web page, named anchors can be used which locates the link
                                   to a specific point on a page.
                                   It can be done in two steps :
                                   Step 1: Point the location to be moved i.e., identify the location in a Web page by specifying the
                                   location name. This is done by using the NAME attribute of the <A> tag.
                                   Syntax
                                   <A  NAME  =  “file  name.html”>


                                          Example: <A NAME = “loc.html “>
                                   It specifies that location to be moved to loc.html.
                                   Step 2: While moving to a particular Web page and location on the Web page, in addition to the
                                   name of the Web page to be moved to, the name of location of the target on the Web page is
                                   needed.
                                   Syntax
                                   <A  HREF  =  “file  name.htm  #  location_name”>  ...  </A>









          50                                LOVELY PROFESSIONAL UNIVERSITY
   52   53   54   55   56   57   58   59   60   61   62