Just Css Things !!!

Table of contents

No heading

No headings in the article.

  1. What is CSS and why use it ?

Ans:

CSS stands for Cascading Style Sheets.

It's basically used to create good-looking websites by describing how the HTML

elements are displayed on the screen. It also controls the layout of the website.

We can add new looks to our old HTML documents.

We can completely change the look of our website with only a few changes in

CSS code.

  1. What are the different ways to bring CSS into an HTML file?

Ans:

We can add CSS to our projects in the following ways :

1. Inline styling.

2. Internal styling.

3. External styling.

  1. What do you mean by specificity in CSS?

Ans:

When more than one set of CSS rules apply to the same element, the browser will have to decide which specific set will be applied to the element. The rules the browser follows are collectively called Specificity

Specificity Rules include:

  • CSS style applied by referencing external stylesheet has lowest precedence and is overridden by Internal and inline CSS.

  • Internal CSS is overridden by inline CSS.

  • Inline CSS has highest priority and overrides all other selectors.

Example:

<html\>

<head\>

<link rel="stylesheet" type="text/css" href="external.css">

<style type="text/css">

h1 {

background-color: red;

color: white;

}

h2 {

color: blue;

}

</style\>

</head\>

<body\>

<h1\>

Internal CSS overrides external CSS

</h1\>

<h2 style="color: green;">

Inline CSS overrides internal CSS

</h2\>

</body\>

</html\>