[go: up one dir, main page]

0% found this document useful (0 votes)
16 views2 pages

Ways CSS Can Be Added To HTML

CSS can be added to HTML in three ways: inline CSS, where styles are applied directly within an HTML element; internal CSS, where styles are defined in a <style> tag in the <head> section; and external CSS, where styles are written in a separate file and linked using a <link> tag. Each method allows for different levels of styling control and organization. Examples illustrate how to implement each method effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Ways CSS Can Be Added To HTML

CSS can be added to HTML in three ways: inline CSS, where styles are applied directly within an HTML element; internal CSS, where styles are defined in a <style> tag in the <head> section; and external CSS, where styles are written in a separate file and linked using a <link> tag. Each method allows for different levels of styling control and organization. Examples illustrate how to implement each method effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ways CSS Can Be Added to HTML

CSS (Cascading Style Sheets) is used to style HTML elements. It can be added to HTML in three

main ways:

1. Inline CSS

CSS is written directly inside an HTML element using the 'style' attribute.

Example:

<p style="color: blue; font-size: 16px;">This is a paragraph with inline CSS.</p>

2. Internal CSS

CSS is written within a <style> tag inside the <head> section of the HTML document.

Example:

<!DOCTYPE html>

<html>

<head>

<style>

body {

font-family: Arial, sans-serif;

h2 {

color: green;

</style>
</head>

<body>

<h2>This is styled using Internal CSS</h2>

</body>

</html>

3. External CSS

CSS is written in a separate file (e.g., style.css) and linked to the HTML document using a <link>

tag.

HTML File:

<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" href="style.css">

</head>

<body>

<h2>This is styled using External CSS</h2>

</body>

</html>

style.css:

h2 {

color: red;

text-align: center;

You might also like