Absolute vs. Relative Paths/Links

Slides:



Advertisements
Similar presentations
How To Make Your Own Web Page: Basic Web Design
Advertisements

XP 1 Developing a Basic Web Site Tutorial 2: Web Site Structures & Links.
Introduction to HTML Lists, Images, and Links. Before We Begin Save another file in Notepad Save another file in Notepad Open your HTML, then do File>Save.
Links and Comments.
Announcement #1 1 Lecture 9. Announcement #2  Midterm exam will be on Oct. 12 (Tuesday)  pm – 1.45 pm  Exam will cover all materials till Oct.
AdvWeb-1/15 DePaul University SNL 262 Web Page Design Links In HTML Instructor: David A. Lash.
AdvWeb-1/13 DePaul University SNL 262 Web Page Design Links In HTML Instructor: David A. Lash.
HTML. We’ll learn … What HTML is What tags are What a basic web page looks like What 3 HTML tags are required What HTML comments look like How to title.
Internal and External Links Web Design – Section 3-6 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
INTRODUCTION TO DREAMWEAVER 8. What we already know…  Design basics  Contrast  Repetition  Alignment  Repetition  HTML.
INFSCI  Last time we built a doggie web page in class following the instructions in the slide deck: Build Web Page with HTML – see week 3 The topics.
Shows the entire path to the file, including the scheme, server name, the complete path, and the file name itself. Same idea of stating your full name,
Links in HTML. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another web page on the same.
Pre-Coding Web Design – Sec 3-1 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
.  Entertain  Inform  Educate  Blogs  Sell  Date  Gamble  Religion.
Informatics Computer School CS114 Web Publishing HTML Lesson 2.
Hyperlinks. Linking pages…Hyperlinks 2 Lecture 8  Hyperlink “A clickable HTML element that will direct the web browser to display a different Web page.
Web Design (5) Navigation (1). Creating a new website called ‘Navigation’ In Windows Explorer, open the folder “CU3A Web Design Group”; and then the sub-folder.
 The tag to create a link is called, which stands for anchor.  You put the address of the page to link to in quotes after href=, like the following:
WEB DESIGN UNIT 2 Unit 2 Module 2-5. WHAT HAVE YOU LEARNED?  What is the title tag do? Where does it show?  What are the tags that need to be on every.
Web Design (2) Brackets - introduction. Brackets Brackets is a web design code editor It is an open-source project initiated by Adobe (creator of Dreamweaver)
Dreamweaver Edulaunch Project 1 EQ: What are the key concepts when building the first page of a web site?
Enhancing Your Web Site—Adding Links Web Page **YOU MUST HAVE COMPLETED THE 1ST 3 WEB PAGES BEFORE YOU CAN DO THIS ONE. **YOU SHOULD HAVE COMPLETED THE.
Unit 3 Day 6 FOCS – Web Design. Journal Unit #3 Entry #4 Write the source code that would make the following display on a rendered page: Shopping List.
Introduction to web development and HTML MGMT 230 LAB.
XHTML1 Images N100 Building a Simple Web Page. XHTML2 The Element The src attribute specifies the filename of an image file To include the src attribute.
Planning your site/organization on the Web Please use speaker notes for additional information!
XHTML Hyperlinks. Creating Links to Other Web Pages A link, or hyperlink, is a specially formatted Web page object that the user can click to open a different.
Internal and External Links Web Design – Section 3-6 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
Notes Chapter 10—Adding Graphics. There are two kinds of graphics on the Internet: those you can use on your own Web pages, and those you cannot.  Many.
FUNDAMENTALS OF HTML, XHTML & CSS Lesson 4. THE OBJECTIVES -  In this lesson you will begin coding in HTML to provide the structure  You will learn.
UNIT 2 UNIT 2 Module 3: HTML Lists Overview. List There are two common types of HTML lists Ordered list numbered Unordered list bullet points.
Internal and External Links Web Design – Section 3-6 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
Web Foundations THURSDAY, SEPTEMBER 26, 2013 LECTURE 2: WORKING WITH HTML FILES, HTML BASICS, LINKING.
Site Organization. The Need to Organize Site Files Thus far, we have placed all our site files into the main (root) website folder. As a website becomes.
Hyperlink Basics Relative vs. Absolute Linking. Absolute Linking This type of linking always includes the prefix If you link to someone else’s.
CSCI N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Navigation, Links & Images.
Links in HTML What you need to know….. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another.
Web Authoring with Dreamweaver. Unit Objectives  Be able to define keywords: HTML, HTTP (protocol), browser, web server, client/server, tag, attribute,
Lesson 6 Links. Creating Folders  For every web site/page, you need to create a separate folder  The computer cannot find links if they are not stored.
Compare and Contrast : Blackboard & a Personal Web Page www3.ltu.edu/~s_schneider/howto/faculty.htm You’ll find this presentation (and another) here :
Hit125 application concepts Types of links File paths & directory structures.
1 More About HTML Images and Links. 22 Objectives You will be able to Include images in your HTML page. Create links to other pages on your HTML page.
Introduction to HTML C151 Multi-User Operating Systems.
PATHNAMES LINKS BACKGROUND.  Pathnames in hyperlinks & image tags  Absolute pathnames: for links to web addresses  Relative pathnames: for links to.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
HTML Links and navigation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Your HTML website creating your first html file. Creating an HTML FIle Open note pad from accessories, programs. Write code. Save and view. In 3 Steps.
Click on CIS120/17 to go to website for course. The week of will tell you what is planned for the week and what has been assigned.
HTML. Hyper Text Markup Language Markup your text document The markup is the tag Hyper text means you can jump from place to place Programming language.
Basic HTML Page 1. First Open Windows Notepad to type your HTML code 2.
Revised June 2008 Online PD Basic HTML1 Let’s Try It!  Open Notepad oStart > All Programs > Accessories > Notepad oDon’t get WordPad by mistake – won’t.
Hyperlinks Links for Other Pages. Hyperlink (aka Link) Text (or image) user can click Takes user to different location In general, location can be: On.
Making the website. Get your folders sorted first Create a new folder in “N” called “My hockey website” Create folders inside called “Documents”, “images”
Basic Web Design UVI CELL Dave Gilliss Dave Gilliss
HTML Links CS 1150 Spring 2017.
Objective % Select and utilize tools to design and develop websites.
Site Organization.
BSBEBU401A Review and Maintain a Website HTML
Internal and External Links
Internal and External Links
Objective % Select and utilize tools to design and develop websites.
Site Organization.
How files are organized
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
HTML Introduction Lecture 8.
HTML Structure.
HTML Links CS 1150 Fall 2016.
Website File Management
Presentation transcript:

Absolute vs. Relative Paths/Links A Step-by-Step Explanation and a Example Walkthrough

Absolute vs. Relative Paths/Links: Explanation

Absolute vs. Relative Paths/Links One of the most common things newcomers to HTML get confused about is linking to other pages and sites, especially when absolute and relative paths come into play. But worry not! Creating links — relative and absolute alike — is actually fairly easy. Read on, and by the end of this presentation, you'll know the difference between these two types of links, as well as when and how to use them. Of course, it's still important to understand how relative and absolute links work, so continue forward...

Absolute vs. Relative Paths/Links First off, as you may or may not know, you would use the following code to create a link in HTML: <a href="page2.html">Page 2</a> page2.html would be the page you want to link to, and Page 2 would be the link that the page displays. In the example above, we used a relative path. You can tell if a link is relative if the path isn't a full website address. (A full website address includes http://www.) As you may have guessed, an absolute path does provide the full website address.

Absolute vs. Relative Paths/Links Here are a few basic examples of relative and absolute paths: Relative Paths index.html /pages/page1.html ../resources/resource1.html Absolute Paths http://www.googgle.com http://www.yahoo.com http://www.bing.com The first difference you'll notice between the two different types of links is that absolute paths always include the domain name of the website, including http://www., whereas relative links only point to a file or a file path. When a user clicks a relative link, the browser takes them to that location on the current site. For that reason, you can only use relative links when linking to pages or files within your site, and you must use absolute links if you're linking to an external location on another website.

Absolute vs. Relative Paths/Links When a user clicks a relative link, how does their browser know where to take them? Well, it looks for the location of the file relative to the page where the link appears. (That's where the name comes from!) Let's get back to our first example: <a href="page2.html">Page 2</a> This link points to a filename, with no path provided. This means that page2.html is located in the same folder as the page where this link appears. If both files were located in the "root" directory of the website http://www.website.com, the actual website address the user would be taken to is http://www.website.com/page2.html. If both files were located in a "sub" folder of the root directory called pages, the user would be taken to http://www.website.com/pages/page2.html.

Absolute vs. Relative Paths/Links How about another example? Let's say we our http://www.website.com domain had a subfolder called resources. Inside the resources folder is a file called resources1.html. The full path to this page would be: <a href="http://www.website.com/resources/resources1.html">Resources 1</a> Still with me? Good. Let's say in this resources1.html file, we have a link: <a href="resources2.html">Resources 2</a> If someone clicked that, where do you think it would take them? If you said http://www.website.com/resources/resources2.html you'd be right! You probably know why it would take them there -- because both files are saved in the resources subfolder.

Absolute vs. Relative Paths/Links Now, what if we wanted to use a relative link to show a page in another folder? If you want to link to a file in a subfolder of the current folder, provide the file path to that file, like so: <a href="/oldresources/oldresources1.html">Old Resources 1</a> In this example, you're telling the browser to look in the current folder (resources) for a subfolder (oldresources) that contains the file you want the user taken to (oldresources1.html). You can link to as many subfolders as you need using this method.

Absolute vs. Relative Paths/Links What if you want to link to a file in a folder above or outside the current folder? You have to tell the browser to move up one folder in your relative link by putting two periods and a slash (../) in front of the filename or path: <a href="../resources1.html">Resources 1</a> When the browser sees ../ in front of the filename, it looks in the folder above the current folder. You can use this as many times as you need to. You can also tell the browser to look in a subfolder of the directory above the current one.

Absolute vs. Relative Paths/Links Using the same example website from above, let's say we wanted to create a link from a page in the oldresources folder that would take the user to a page in the resources folder and also create a link to the home page (index.html) in the root directory. Here's how a relative link to this file would look going from a page in oldresources back to a page in resources: <a href="../resources1.html">Home</a> Here's how a relative link to the home page would look going from a page in oldresources back to the root folder: <a href="../../index.html">Home</a>

Absolute vs. Relative Paths/Links Now, let's talk about absolute paths. Like we mentioned earlier, absolute paths provide the complete website address where you want the user to go. An absolute link would look like this: <a href="http://www.google.com">Google</a> You must use absolute paths when linking to another Website, but you can also use absolute paths within your own website. This practice is generally frowned upon, though. Relative links make it easy to do things like change your domain name without having to go through all your HTML pages, hunting down links and changing the names. As an added bonus, they force you to keep your site structure neat and organized, which is always a good idea.

Absolute vs. Relative Paths/Links: Example Walkthrough

The "Root" Directory, index.html file, and "Sub" Folders Let's say I have a folder with one (1) index.html file in it and four (4) sub folders called pages, resources, images, and docs. The folder that holds this index.html file and the four sub folders is called the "root" directory. Every website has a "root" directory and most websites have an index.html file which acts as its main "home" or portal page located in this "root" directory. Link Demo Online: http://faculty.cascadia.edu/cduckett/bit116/linkdemo Link Demo Download: http://faculty.cascadia.edu/cduckett/bit116/linkdemo.zip Link Demo Video Walkthrough: http://faculty.cascadia.edu/cduckett/bit116/videos/linkdemo.mp4

The pages folder Inside the pages folder, I have three (3) html files named pages1.html, pages2.html, and pages3.html

The resources folder Inside the resources folder, I have three (3) html files named resources1.html, resources2.html, and resources3.html. Also inside the resources folder is a sub folder called old which contain three html files called oldresources1.html, oldresources2.html, and oldresources3.html

The docs folder Inside the docs folder, I have three (3) Word document files named document1.docx, document2.docx, and document3.docx.

The images folder Inside the images folder, I have several image files (jpg and png formats) which I can display as needed in my web pages

The index.html file The index.html file is the "home" page which links to other pages in the site. In this example, the index.html is the only html page that is located in the "root" directory—all the other html pages in the site are located inside the pages and resources sub folders

The index.html file The index.html page links to pages inside of subfolders (e.g., pages1.html, resources1.html) using the relative linking method, and it also links to external pages (e.g., Google, Yahoo, Bing) using the absolute linking method.

The index.html file When the index.html page links to a page inside of the pages subfolder that folder's name needs to be included as part of the link, like so: <a href="pages/page1.html">Page 1</a> Basically, what this link is saying is "look inside the pages folder for a file called page1.html and open it."

The index.html file When the index.html page links to a page inside of the resources subfolder that folder's name needs to be included as part of the link, like so: <a href="resources/resources1.html">Resources 1</a> Basically, what this link is saying is "look inside the resources folder for a file called resources1.html and open it."

The index.html file When the index.html page links to a page inside of the docs subfolder that folder's name needs to be included as part of the link, like so: <a href="docs/document1.docx">Document 1</a> Basically, what this link is saying is "look inside the docs folder for a file called document1.docx and open it."

The index.html file When the index.html page links to a page inside of the images subfolder that folder's name needs to be included as part of the link, like so: <a href="images/triune.jpg">Image</a> Basically, what this link is saying is "look inside the images folder for a file called triune.jpg and open it." You can also use the img tag to link to and embed an image directly into a web page, using: <img src="images/home.jpg"> triune.jpg as a page home.jpg embedded

Linking from pages inside pages folder to pages outside pages folder When linking to the index.html page from a page inside the pages folder, you need to include ../ (the "dot dot slash") as part of the link. <a href="../index.html">Home</a> The .. ("dot dot") part of the .. / ("dot dot slash") means "step outside of or 'back out' of the current folder." The / ("slash") part of the .. / ("dot dot slash") means "look for the file or folder that comes after it, and open it."

Linking from pages inside pages folder to pages outside pages folder Looking at the folders we can see that the index.html page is one level outside of the pages folder; the ../ (the "dot dot slash") is telling the link to back out of the pages folder one level and then look for the index.html file and open it. <a href="../index.html">Home</a>

Linking from pages inside a folder inside a folder to a different folder The resources folders has three html files in it as well as a subfolder called old which also has three html files in it. To link to a file inside the old folder to a file inside the resources folder, you'd use ../ and the files name because you only have to back out one level <a href="../resources1.html">Resources 1</a> To link back to the index.html file from the old folder you'd have to use ../ twice because you have to back out two levels to find it: <a href="../../index.html">Home</a>

Linking from pages two levels out and into a different folder To link to a file inside the old folder to a file inside the pages folder, you'd use ../ twice, then the name of the pages folder, and finally the filename because you have to back out two levels and before going into the pages folder to find the file <a href="../../pages/pages.html">Page 1</a> The same is true is you want to link to a file in the docs folder or the images folder.