Site icon TestingDocs.com

Cascading Style Sheets

Overview

CSS is a stylesheet language that describes the presentation of an HTML/XML document. CSS stands for Cascading Style Sheets.

CSS describes how HTML elements must be rendered on the screen, or in other media. CSS is used to describe the Look & Feel and to format HTML documents written in a markup language like HTML.

Learning CSS is easy and is a must for anyone working with web design. CSS web designers should have basic knowledge of HTML and JavaScript.

We can specify the CSS inline, within the HTML or refer to an external stylesheet. External stylesheets are stored in the *.css files.

The main advantage of CSS is that we can declare the presentational style attributes only once in the .css file.

CSS Syntax

CSS uses a number of English keywords to specify the names of various style properties. A CSS rule-set consists of a CSS selector and a CSS declaration block.

The general CSS syntax is as follows:

selector { property: value; }

The selector is the HTML element that we want to style.

The CSS declaration block contains one or more declarations separated by
semicolons. A CSS declaration always ends with a semicolon.

{ property: value; } is a declaration block that consists of a list of declarations in braces. Each declaration itself consists of a CSS property, a colon (:) and a value. Multiple declarations can be inserted in a single block.

Example

Some examples are as follows:

h1 { color: blue; }

The CSS code will make all the h1 headings in the document blue in color.

Multiple CSS declarations

h1 { color: blue; font-size:24px; }

Advantages

CSS is used to define the styles of web pages, including the design, layout, and variations in display for different devices and screen sizes. For example, the layout of the web pages on a computer screen, laptop screens, tablets, mobile device screens, etc. CSS can control the layout of multiple web pages all at once.

Insert CSS

To insert CSS code to a web page:

https://www.testingdocs.com/insert-css-code-to-an-html-document/

HTML Tutorials

HTML Tutorials on this website:

https://www.testingdocs.com/html-tutorials/

More Information on HTML:

https://www.w3.org/TR/html401/intro/intro.html

Exit mobile version