Web Lab Program3
Web Lab Program3
Develop an external style sheet named as “style.css” and provide different styles for h2, h3, hr, p,
div, span, time, img & a tags. Apply different CSS selectors for tags and demonstrate the significance
of each.
Style.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<main id="main-content">
sibling selector.</p>
<hr>
attribute selector.</p>
<section>
class selector.</p>
selector.</p>
</section>
2023</time></p>
<p>Notice how the first letter of each paragraph is styled differently.</p>
<article class="special">
</article>
<img
src="https://d3njjcbhbojbot.cloudfront.net/api/utilities/v1/imageproxy/https://
images.ctfassets.net/wp1lcwdav1p1/6z473u5f7WaFUnr9GxDEk2/085274c4a84
1bd2dc900ebca36c43c9c/GettyImages
1255905237.jpg?w=1500&h=680&q=60&fit=fill&f=faces&fm=jpg&fl=progre
image">
</main>
</body>
</html>
Style.css
/* Element Selector */
h2 {
color: #2c3e50;
padding-bottom: 10px;
h3:hover {
color: #e74c3c;
cursor: pointer;
}
/* Element Selector */
hr {
border: 0;
height: 1px;
p[lang] {
font-style: italic;
/* Class Selector */
.highlight {
background-color: #f1c40f;
padding: 5px;
/* ID Selector */
#main-content {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #ecf0f1;
/* Descendant Selector */
div p {
line-height: 1.6;
margin-bottom: 15px;
/* Child Selector */
font-weight: bold;
color: #16a085;
h2 + p {
font-size: 1.1em;
color: #7f8c8d;
/* Attribute Selector */
time[datetime] {
color: #8e44ad;
font-weight: bold;
/* Pseudo-element Selector */
p::first-letter {
font-size: 1.5em;
font-weight: bold;
color: #c0392b;
/* Multiple Selectors */
img, a {
padding: 5px;
a:link, a:visited {
color: #3498db;
text-decoration: none;
a:hover, a:active {
color: #e74c3c;
text-decoration: underline;
}
img[alt] {
max-width: 100%;
height: auto;
/* Combining Selectors */
div.special p {
text-indent: 20px;
color: #27ae60;