Q4 - Module5 - G10 - Programming Ii
Q4 - Module5 - G10 - Programming Ii
10 TVL- ICT
COMPUTER PROGRAMMING
QUARTER 4 – MODULE 5
CSS LINKS
Prepared by:
JOEL A. MANIO
Teacher III
San Jacinto National High School
0
QUARTER IV
WEEK IV
I. LEARNING OBJECTIVES
After reading this module you will be able to learn the how to use link using CSS.
II. INTRODUCTION
This module teaches you how to set different properties of a hyper link using CSS.
You can set following properties of a hyper link.
III. READINGS/LECTURES
LINK – This will connect site from another site or specified location defends on the
programmer or programmer called hyperlink.
VISITED – It's meant to help users distinguish the difference between links they have
and haven't visited.
HOVER - selector is used to select elements when you mouse over them.
ACTIVE - A hyperlink is considered to be an active hyperlink from the time a user
presses and releases the mouse button when clicking on the hyperlink.
TEXT DECORATION - The text-decoration property is mostly used to remove
underlines from links.
BACKGROUND COLOR - The background-color property can be used to specify a
background color for links.
LINK
The :link CSS pseudo-class represents an element that has not yet been visited. It matches
every unvisited <a> or <area> element that has an href attribute.
The following example shows Link Style:
<!DOCTYPE html>
<html>
<head>
<style>
1
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
</head>
<body>
<h2>Link Button</h2>
<p>A link styled as a button:</p>
<a href="default.asp" target="_blank">This is a link</a>
</body>
</html>
Output:
VISITED
The :visited CSS pseudo-class represents links that the user has already visited.
For privacy reasons, the styles that can be modified using this selector are very limited.
The following example shows Link styles:
<html>
<head>
<style type = "text/css">
a:visited {color: #006600}
</style>
</head>
<body>
<a href = ""> link</a>
</body>
</html>
2
Output:
HOVER
The :hover CSS pseudo-class matches when the user interacts with an element with
a pointing device, but does not necessarily activate it. It is generally triggered when the
user hovers over an element with the cursor (mouse pointer).
The following example demonstrates how to change the color of links when we bring a
mouse pointer over that link. Possible values could be any color name in any valid format
The following example shows Hover link:
<html>
<head>
<style type = "text/css">
a:hover {color: #FFCC00}
</style>
</head>
<body>
<a href = "">Link</a>
</body>
</html>
Output:
ACTIVE
The :active CSS pseudo-class represents an element (such as a button) that is
being activated by the user. When using a mouse, "activation" typically starts when the user
presses down the primary mouse button.
The following example demonstrates how to change the color of active links. Possible values
could be any color name in any valid format.
The following example shows Active link:
<html>
<head>
<style type = "text/css">
a:active {color: #FF00CC}
3
</style>
</head>
<body>
<a href = "">Link</a>
</body>
</html>
Output:
TEXT DECORATION
The text-decoration shorthand CSS property sets the appearance of decorative lines on text.
It is a shorthand for text-decoration-line , text-decoration-color , text-decoration-style , and
the newer text-decoration-thickness property.
The following example shows all these border widths:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
</style>
</head>
<body>
<h2>CSS Links</h2>
<p><b><a href="default.asp" target="_blank">This is a link</a></b></p>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in
order to be effective.</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be
effective.</p>
</body>
</html>
4
Output:
BACKGROUND COLOR
The background-color property sets the background color of an element.
The background of an element is the total size of the element, including padding and border
(but not the margin). Tip: Use a background color and a text color that makes the text
easy to read.
The following example shows Background Color:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
background-color: yellow;
}
a:visited {
background-color: cyan;
}
a:hover {
background-color: lightgreen;
}
a:active {
background-color: hotpink;
}
</style>
</head>
<body>
<h2>CSS Links</h2>
<p><b><a href="default.asp" target="_blank">This is a link</a></b></p>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in
order to be effective.</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be
effective.</p>
</body>
</html>
Output:
5
ACTIVITY 1: Select your answer on the box the letter can be repeat on your answer.
A. Link B. Visited C . Hover D. Active E. Text Decoration
F. Background Color G. Background
SUMMATIVE EVALUATION
6
2. Link is a link when the user mouses over it
3. Visited link is a link the user has visited
4. Active is a link the moment it is clicked
5. The background-color property can be used to specify a background color for
links
6. The text-decoration property is mostly used to remove underlines from links
7. When setting the style for several link states, a:link MUST come after a:hover and
a:visited
8. There are three links states in CSS.
9. When setting the style for several link states, a:active MUST come after a:hover
10. With CSS, links can be styled in different ways.
</body>
</html> >
7
References: https://www.w3schools.com/css
Learn to Code HTML & CSS –Develop and Style Website by: Shay Howe
ANSWER SHEET