The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> link format, links for images etc
steve72
post Sep 27 2006, 05:56 AM
Post #1





Group: Members
Posts: 4
Joined: 20-September 06
Member No.: 180



hi i am new to html and trying to teach myself but havent grasped the concept of links.
can anyone advise.when creating link in html say for a background image i have been using something like

<BACKGROUND="c:\CoombeDeanEaglesWeb\homepage.jpg"> so i can view this to check my work, i assume this is incorrect because when i upload to my web host the link doesnt work and dont understand when "absolute" or "relative" links are used.
can anyone advise what the link would be IF uploaded to "htdocs" folder on my web hosts server and can the same code be used for viewing when testing site not uploaded. i.e is the link CHANGED when uploading or is there a consistant code you can used for testing and AFTER uploading.
sorry for the basic question and hope you serious coders dont feel insulted by such a trivial question.

thanks in anticipation
steve

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 27 2006, 07:08 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(steve72 @ Sep 27 2006, 12:56 PM) *

hi i am new to html and trying to teach myself but havent grasped the concept of links.


See this FAQ entry: http://htmlhelp.com/faq/html/links.html#link-howto

QUOTE

can anyone advise.when creating link in html say for a background image


You can only create links for plain text:

CODE
    <a href="">link text</a>


or HTML elements (like an inline image):

CODE
    <a href=""><img src="dog.jpg" width="100" height="50" alt=""></a>


Since a background image is not an HTML element, it can only be a decoration of an HTML element. But you can use a background image for a link with CSS. Here's a quick example (but I advice against using the STYLE attribute in normal circumstances since it's only practical for demonstration purposes):

CODE
    <a href="" style="background-image: url(dog.jpg);">link text</a>


QUOTE
i have been using something like

<BACKGROUND="c:\CoombeDeanEaglesWeb\homepage.jpg"> so i can view this to check my work, i assume this is incorrect because when i upload to my web host the link doesnt work


"<BACKGROUND..." implies there's a BACKGROUND element, but there is no such element in HTML. "c:\CoombeDeanEaglesWeb\homepage.jpg" is a file path on your local computer, but on the web you must use forward slashes "/" to separate directories, and the file path should point to an image uploaded to your web host account. Also case is important on the web, it becomes easier if you always use lower case names for files and directories.

QUOTE
and dont understand when "absolute" or "relative" links are used.


Parts of this a bit technical: http://htmlhelp.com/faq/html/basics.html#relative-url but as long as the image and HTML document are located in the same directory you can use the simplest relative URL, like "foo.html" here:

CODE
<a href="foo.html">link text</a>


QUOTE
can anyone advise what the link would be IF uploaded to "htdocs" folder on my web hosts server


Why should you upload it there? AFAIK that directory is for server configuration files, and is normally hidden from normal user accounts. Besides that, see above. smile.gif

QUOTE
and can the same code be used for viewing when testing site not uploaded. i.e is the link CHANGED when uploading or is there a consistant code you can used for testing and AFTER uploading.


If you use relative paths they usually work the same in both cases. Absolute paths will not.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 09:00 PM