How to add CSS to HTML

Leave a Comment
Let's see how we can add CSS to our website / blog page.

From a file

If you have our style sheets in a file called 'style.css' you'll add the following inside the tag <head>:
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
You can replace the file 'style.css' with a URL, or if you have it inside a folder: '/ folder / style.css' .

Inside the HTML document

As simple as writing styles inside these tags, located (again) within <head>:
<style media="screen" type="text/css">



</style>

Within a tag

We just have to add the 'style' attribute and our CSS rules:
<p style="color:blue;">Blue paragraph</p>

Importing CSS file

We can also import a CSS stylesheet from another file (which can be a URL) using @import:
 @ import 'file.css'; 
More about 'import '.

0 comentarios:

Publicar un comentario