You are on page 1of 3

CSS with HTML

For styling html elements we use Cascading Style Sheet (CSS). By using
CSS we can add colors, animations, images, videos and add
responsiveness to websites. So CSS is essential to make great website.

There are three ways to add CSS in HTML.

1. Inline CSS

2. External CSS

3. Internal CSS

Inline CSS

Using Style Attribute to HTML element. This is used when there is very
small need to add CSS to HTML. Here is the example.
<h1 style="color:red;">A RED Heading</h1>

<p style="color:red;">A red paragraph.</p><body style="font-color:red">


All text in body will red.</body>

External CSS

An external style sheet is used to define the style for many HTML pages,
ie. for large codes.

To use an external style sheet, add a link to it in the <head> section of


each HTML page.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Here is the style.css file in which you need to add code.


body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}

Internal CSS

Here the CSS code will be written in the HTML file it self in <head> tag.
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

HTML Links

Links are used to link one page to other page. When user will click on the
like he/she will redirected to the document that is linked with that link.
Link can be text, image, video or any clickable element of web document.
Also called hyperlink.

<a href="www.medium.com">Medium</a>
OR
<a href="www.medium.com"><img src="img.png"></a>
OR
<a href="mailto:someone@example.com">Send email</a>

You might also like