❐CSS❐

❐wD Learn

CSS

CSS Introduction

CSS Selectors

CSS Color

CSS Background

CSS Border

CSS Margin

CSS Padding

CSS Box Model

CSS Text

CSS Font

CSS Link

CSS List

CSS Overflow

CSS Display

CSS Combinators

CSS Pseudo-classes

CSS Navigation Bar

CSS Hover

CSS Z-index

CSS Media Queries

CSS Shadow

CSS 2D Transform

CSS Animations

CSS Button

CSS FlexBox

CSS Grid

CSS Pagination

Ways To Add CSS There are three different ways to add CSS to an HTML page, which are: Inline CSS Inline CSS is used to add custom properties to specific elements. The added style will only reflect on that particular element only.

To use inline CSS, insert the style attribute within the HTML element's opening tag.

In given Example the inline style of color: purple is attached to only the h1 tag.

Example


<h1 style="color: purple;">I'm harry</h1>
<h2>I'm web</h2>
Internal CSS Internal CSS is used to apply custom style to multiple elements on the same page. The style can be used throughout the HTML page.

Internal CSS is defined in a style block, which will be inside the head section.

In Following example the style block, selector p will target all p tags and assign them color: red.

Example


<head>
<style>
.p {
color: red;
}
</style>
</head>
<body>
<h1>Hello</h1>
<p>I'm Web Developer</p>
<p>Thank you</p>
</body>
External CSS External CSS works similarly to internal CSS but with a twist.

Instead of adding the styles within the HTML file, we create a separate file with a .css extension.

This file will hold all the styling details. Then, we link this file to the HTML page, giving it the instructions on how to look.

There is a new <link> tag in the head section, and this link tag has rel and href properties.

Example


<head>
<title>CodeWithHarry</title>
<link rel="stylesheet" href="style.css">
</head>
<body> <p>I'm student, from college</p>
<p>I'm a Developer </p>
</body>