170 likes | 216 Views
Dive into the world of HTML attributes, understand their importance, control element appearance, align text, handle images, and more. Practice coding and enhance your web development skills effectively.
E N D
What we have learned so far: 2.1 Basic HTML page development 2.2 Tags… (example?) 2.3 Lists… (example?) 2.4 Single Tag… (example?) Some useful resources: http://htmlhelp.com/reference/wilbur/list.html http://www.w3schools.com/ A quick 10 min. in-class quiz Lecture 8
Today, we will cover • Attributes of tags • Some more tags - Image handling in HTML • In-class webpage development Lecture 8
What if I decide to change the style of the texts inside the Tags?Attributes in Tags Lecture 8
Attributes in tags • Attribute - a property of an HTML element (tag) • Control appearance of elements in the document • consists of • attribute_name and • attribute_value • used with opening tag • General syntax <tagname attribute_name=“value1”>content</tagname> Lecture 8
The Attributes • Example: ALIGN attribute • Used for aligning text in a web browser • attribute_name: ALIGN • atribute_value: LEFT | CENTER | RIGHT • Example usage: • Earlier we used: <H1>Welcome to MAT 279</H1> • Now: <H1 ALIGN = “CENTER”>Welcome to MAT 279</H1> • There are many attributes we will learn in this class • Some of them can be readily used with most of the tags • Some are tag-specific Lecture 8
The Attributes (contd.) Lecture 8
More recent: style attribute • controls how the browser displays an element • used with opening tag • syntax <elementstyle=“rules” … > content </element> • rules • a set of style rules • entered by specifying a style name followed by a colon and then a style value style=“name1:value1; name2:value2; …” • e.g. <h1 style=“text-align:center”>Welcome to MAT 279</h1> <h1 style=“color: blue”>Welcome to MAT 279</h1> <h1 style=“text-align:center; color:blue”>Welcome to MAT 279</h1> Lecture 8
Image Handling • So far, we have covered text handling • Now, we will learn how to do image handling • What is the tag for image element? Lecture 8
Image tag • <IMG> tag: place images on Web Pages • One sided tag • Necessary attributes for <img>: • src attribute: specifies name of image file • attribute_name: src • attribute_value: source file name • alt attribute, give your image a hidden name • attribute_value: a hidden name of your image • example: • <IMG src=“JJ_logo.jpg” alt=“JJ logo”> Lecture 8
Image tag (contd.) • How to specify size of the image file to be displayed? • Use attributes • attribute_name: width, height • attribute_value: define the width or the height of image • example: <IMG src=“logo.jpg” width=“100” height=“200” alt=“Dave’s logo”> Lecture 8
Image tag (contd.) • Width and height attribute • attribute_value: define the width or the height of image • Two types of units • Pixels: number of pixels (eg, “100px” or just “100”) • Percent: (eg, “20%”) • example: <IMG src=“logo.jpg” width=“100” height=“200” alt=“Dave’s logo”> Lecture 8
Image tag (contd.) • place an image in center of a browser • Use <CENTER>, … </CENTER> tag • example <CENTER> <IMG src=“logo.jpg” width=“100” height=“200” alt=“Dave’s logo”> </CENTER> • Alternatively, <h1 style=“text-align:center”><IMG src=“logo.jpg” width=“100” height=“200” alt=“Dave’s logo”> </h1> Lecture 8
Few things to remember: • Use image files in .gif, .jpg, .png format • Do NOT use .bmp, .tiff, .pict • Use images with small size Lecture 8
NOTE • When inserting an image, make sure that the image file is located at the same disk directory as shown in your src attribute in <IMG> tag • Example • if <IMG src=“logo.jpg” …> is used in your html file, then the image file (logo.jpg) MUST be installed in the same disk and same file folder with your html file! Lecture 8
In-class Practice – design this webpage Lecture 8
An interesting attribute – “title” • title can also be used as an attribute • Shows a pop-up title for your element • Mostly used with images for description • General syntax • title=“value” <IMG src="streetsign.jpg" width="75" height="75" alt="JJ logo" title="JJ logo"> Lecture 8