CSS - Cascading Style Sheets

CSS is the language used to style an HTML document.
CSS describes how HTML elements should be displayed.

Why Use CSS?
CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.

CSS Syntax
A CSS rule consists of a selector and a declaration block.
The selector points to the HTML element.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons.
Declaration blocks are surrounded by curly braces.

p {
  color: red;
  text-align: center;
}

CSS Selectors
1) CSS element Selector
p {
  text-align: center;
  color: red;
}
2) CSS id Selector
#para1 {
  text-align: center;
  color: red;
}
3) CSS class Selector
.center {
  text-align: center;
  color: red;
}
4) CSS Universal Selector
* {
  text-align: center;
  color: blue;
}
5) CSS Grouping Selector
h1, h2, p {
  text-align: center;
  color: red;
}

Ways to Insert CSS
External CSS
- External stylesheets are stored in CSS files.
Internal CSS
- An internal style sheet may be used if one single HTML page has a unique style.
- The internal style is defined inside the <style> element, inside the head section.
Inline CSS
- An inline style may be used to apply a unique style for a single element.
- Add the style attribute to the relevant element. The style attribute can contain any CSS property.

Cascading Order
Inline style (inside an HTML element)
External and internal style sheets (in the head section)
Browser default


Comments

Popular posts from this blog

PL/SQL

JAVA8 Features

Build Automation