Affiliate link

CSS - Introduction

Cascading Style Sheets (CSS) is the language for styling website design. The language is written within HTML or XML.

Why use CSS?

CSS solve the problem of putting fonts, color or any styling in HTML attributes for all web pages.
CSS can be stored in an external file to use in multiple web pages.

<style type="text/css">
    h1 {
       color: #0070f3; 
    }
</style>
<h1>Learn CSS at LearnCodeNow</h1>

Code Result

CSS styles definition

CSS - Inline CSS in HTML

Define CSS styles with HTML element style.

<style type="text/css">
    h1 {
       color: #0070f3; 
    }
</style>
<h1>Learn CSS at LearnCodeNow</h1>

CSS - Inline CSS in style attribute

Define CSS styles with HTML attribute style.

<h1 style="color: red;">Learn CSS</h1>

CSS - External File

Define CSS styles in .css file.

/* Learn CSS comments */
h1 {
    color: #0070f3; 
}

CSS - Import css with link or @import

To import external CSS file in your HTML, you can use <link> or @import.

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="mystyle.css" media="all"></link>
        <style type="text/css">
            @import url(mystyle.css)
        </style>
    </head>
    <body>
    </body>
</html>

CSS - Comments

To add comments to CSS.
Use <!-- --> for CSS in HTML.
/* */ for external .css file.

<style>
    /* Learn CSS comments */
    h1 {
        color: #0070f3; 
    }
</style>
Affiliate link
Affiliate link
Affiliate link
Advertisment
StudioPress
Fiverr
Ad - SiteGround WooCommerce hosting - best home for your online store. Fast WooCommerce, Free SSL, Top support. Learn more.