Chapter4 5 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CHAPTER -4

CSS ATTRIBUTES AND BACKGROUND

Style attributes can be used to bring a change in the appearance of the concerned
element.Some of the commonly used attributes are color,text-align etc
Attributes
1.color:Specifies the text-color of an element
2.text-align: Web browsers, by default, align content to the left. CSS lets you justify
content or align it to the left, right, or center. You can change the way text is aligned using
the text-align CSS property.

3.font-size: To change the size of your text, you can use the CSS property font-size.It
is mentioned in percentage like 200%,300% etc.

font-size:150%

4. float Property

The float property enables us to make an element float to the left or right side of its
container.Its values are left and right.
CHAPTER 5
INSERTING IMAGES

Most HTML pages contain images. Images are used to grab the attention of the
user. Adding images to a page greatly improves the look and feel of a web page.
Image Element
The <img> element is used to add an image to the web page. You can add
images that are on your web server or from a different website.

Src Attribute
The src attribute tells the web browser the location of the image relative to the
web page. The src attribute is mandatory. To add an image, the src attribute
must be set to the location where the image can be found.

This example below includes code for displaying an image on a web page.

<html>

<head>

<title>Adding an Image</title>

</head>

<body>

<img src=“../Pictures/treesunsetthumbnail.jpg" >

</body>

</html>
Image Attributes

Alt Attribute
The alt attribute contains a description of the image in text form. Browsers
display the contents of this attribute when the image cannot be loaded (due to a
slow connection or an error loading the image).

Here is an example of the img element with the alt attribute.

Width and Height Attribute


Many times, we want to change the size of the image displayed on a web page.
To do this, we can use the width and height attributes of the img element.
The width attribute specifies the width of the image displayed while
the height attribute specifies the height of the image displayed.
Here is an example of the img element with the height and width attributes.

<html>
<head>
<title>Lake and Mountains</title>
</head>
<body>
<img src="lake-and-mountains.jpg" alt="Lake and Mountains"
height="180" width="270">
</body>
</html>

Which attribute of image is used when the image is not displayed?


a. src b. alt c. alter

You might also like