web design - working with links and images

18
Fundamentals of Web designing Ministry of Higher Education Bamyan University Computer Science Department 1 Presented by : Mustafa Kamel Mohammadi Email : [email protected] Working with Links and Images

Upload: mustafa-kamel-mohammadi

Post on 15-Jan-2017

25 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Web design - Working with Links and Images

1

Fundamentals of Web designing

Ministry of Higher EducationBamyan University

Computer Science Department

Presented by : Mustafa Kamel MohammadiEmail : [email protected]

Working with Links and Images

Page 2: Web design - Working with Links and Images

2

learning objective In this chapter you will learn

How to work with text in HTML Define paragraphs and headings Define different types of lists

Page 3: Web design - Working with Links and Images

3

What are links? Hyperlinks, or simply links, connect HTML pages to other resources on the Web. Links causes to connect you pages with

Other pages in other website Pages within your site Some area in your page

Page 4: Web design - Working with Links and Images

4

How to create links? To create a link we almost need three components

The web address or URL that we want to browse to it through the link Some text to label the link for being more understandable for users <a> </a> tag to wrap all those above with an href attribute.

<a href=“ http://www.google.com”>

This links you to google website

</a>

Page 5: Web design - Working with Links and Images

5

Link options You can link to a variety of online resources:

Other HTML pages (either on your Web site or on another Web site) Different locations on the same HTML page Resources that aren’t even HTML pages at all, such as e-mail addresses, pictures, and text files

Page 6: Web design - Working with Links and Images

6

URL types Absolute URL

An absolute URL uses a complete URL to connect browsers to a Web page or online resource for example, (http:// www.website.com/directory/page.html).

Relative links A relative link uses a kind of shorthand to specify the URL for the resource where you’re already

pointing You create relative links between resources in the same domain Because both resources are in the same domain, you can omit domain information from the URL If you use relative links on your site, your links still work if you change either

Servers Domain names

Ex: ( contact.html), (images/new.jpg),…. Use ../(two periods and a slash) before the filename to indicate that the browser should

move up one level in the directory structure. Ex: <a href=”../docs/home.html>Documentation home</a>

Page 7: Web design - Working with Links and Images

7

Common mistakes Even one incorrect letter in your URL can lead to a broken link. Broken links lead to an error page (often the HTTP error 404 File or directory not found). To avoid this error, be careful with these mistakes

Check capitalization Check extension Check file name Copy and paste URL if possible

Page 8: Web design - Working with Links and Images

8

Opening links in a new window Set the “target” attribute of <a></a> tag with the value _blank

Ex:

<a href=“ http://google.in” target=“_blank”>See google.in

</a>

Page 9: Web design - Working with Links and Images

9

Linking to a location in the same webpage In order to do this you must

Spot the location you want to go by assigning ID attribute Set link to point at the spotted location by setting the href attribute of link to the value of ID

Ex: <h2 id=“top” > Welcome to this page</h2>

The pound sign (#) indicates that you’re pointing to a spot on the same page ,not on another page.

<a href=“#top” >go to top of page </a>

Page 10: Web design - Working with Links and Images

10

Linking to non-HTML resources Non-Web files have unique URLs just like HTML pages. Any file on a Web server (regardless of its type) can be linked with its URL.

Ex:

<p><a href=”software.zip”>Software</a></p><p><a href=”doc.pdf”>Documentation</a></p>

Page 11: Web design - Working with Links and Images

11

Email address links A link to an e-mail address can automatically open a new e-mail, addressed to exactly

the right person.Ex:

<p>Send us your<a href=”mailto:[email protected]”>comments</a></p>

Page 12: Web design - Working with Links and Images

12

Adding images on your page The image (<img />) element is an empty element(sometimes called a single-ton tag)that

you place on the page where you want your image to go.Ex:

<img src=“new.jpg” />

The “src” attribute in <img/> tag is the same as link attribute in <a> tag.

Page 13: Web design - Working with Links and Images

13

Adding alternative text ,width and height for images Alternative text is shown to user when the image is not loaded yet due to some

problems, like slower connection, lower graphic processor capability,…

Ex:

<img src=“flower.jpg” alt=“this is a flower” width=“60” height=“100” border=“5”/>

Page 14: Web design - Working with Links and Images

14

Image alignment “align” attribute of <img/> tag control how your image appears relative to the text

around it. Possible values are:

Top Bottom Middle Left Right

<p><img src="new.jpg" align=“top" />this is the text on the top of image

</p>

Page 15: Web design - Working with Links and Images

15

Image spacing You can specify the amount of space between your image and the texts around that by

the following attribtes: Hspace : horizontal spacing for left and right Vspace : vertical spacing for top and bottom

Page 16: Web design - Working with Links and Images

16

Image links You can use images as links by replacing <img/> tag with the text in an <a> tag

Ex:

<p><a href=”http://www.w3.org”><img src=”w3.jpg” alt=”Visit the W3C Web Site” height=”48” width=”315” border=”0” /></a></p>

Page 17: Web design - Working with Links and Images

17

Page 18: Web design - Working with Links and Images

18

References• “HTML 4 dummies 5th edition” by Ed Tittel & Mary Burmeister• “HTML 5 designing rich internet applications” by Mathew Dawid• “HTML in ten simple steps” by Robert G. fuller