Lab File Format
Lab File Format
Experiment No: 3
Experiment Title Implement CSS using all the ways of HTML
Aim: Create a web page to display CSS using HTML
Procedure:
Step 3: Add Internal CSS in the <style> tag inside the <head>.
Step 4: Create a separate CSS file (styles.css) and link it in the HTML file for
External CSS.
Step 5: Run the HTML file in a web browser and observe the output.
Source Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Implementation Example</title>
</head>
<body>
<!-- Inline CSS -->
<h1 style="color: red; font-size: 28px;">Welcome to My Website</h1>
<p style="color: purple; font-size: 18px;">This is an example of inline CSS.</p>
</body>
</html>
<!—for inline-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Implementation Example</title>
</head>
<body>
<!-- Inline CSS -->
<h1 style="color: red; font-size: 28px;">Welcome to My Website</h1>
<p style="color: purple; font-size: 18px;">This is an example of inline CSS.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>External CSS Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<p>This paragraph is styled using external CSS.</p>
</body>
</html>
p{
color: green;
font-size: 22px;
}
Result:
Conclusion:
We successfully implemented CSS using all three methods in an HTML document. External
CSS is preferred for large projects, while internal and inline CSS are useful for specific cases.