Program3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Styled HTML Page</title>
<link rel="stylesheet" href="lab3.css">
</head>
<body>
<!-- h2 and h3 tags with custom styles -->
<h2>This is Heading 2</h2>
<h3>This is Heading 3</h3>
<!-- Horizontal rule -->
<hr>
<!-- Paragraph with default styles -->
<p>This is a simple paragraph styled with a class selector.</p>
<!-- div with id for specific styling -->
<div id="main-content">
<p>Content inside a div styled with an ID selector. This paragraph
belongs to the main content section.</p>
<span class="highlight">This text is highlighted with a class
selector.</span>
</div>
<!-- Time element with custom styling -->
<p>Published on: <time datetime="2024-10-09">October 9, 2024</time></p>
<!-- Image with custom styles -->
<img src="image.jpg" alt="Sample Image">
<!-- Anchor link with hover effect -->
<p>Visit our <a href="https://www.example.com">website</a> for more
information.</p>
</body>
</html>
(CSS)
/* Universal selector - applies to all elements */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Element selector for h2 and h3 */
h2 {
color: darkblue;
font-size: 24px;
text-align: center;
text-transform: uppercase;
}
h3 {
color: darkgreen;
font-size: 20px;
text-align: left;
}
/* Styling horizontal rule (hr) */
hr {
border: 1px solid #888;
margin: 20px 0;
}
/* Class selector for paragraphs */
p {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333;
}
/* ID selector for div */
div#main-content {
background-color: #f2f2f2;
padding: 20px;
border: 1px solid #ddd;
margin: 10px;
}
/* Class selector for span elements */
span.highlight {
color: #ff6600;
font-weight: bold;
}
/* Type selector for time elements */
time {
font-style: italic;
color: #555;
}
/* Styling for images */
img {
max-width: 100%;
height: auto;
border-radius: 8px;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
}
/* Styling for anchor links */
a {
text-decoration: none;
color: #1a73e8;
}
a:hover {
color: #ff0000;
}
/* Grouping selectors for common styling */
h2, h3, p {
margin-bottom: 20px;
}
Comments
Post a Comment