Docsity

CSS: Styling Web Pages with Cascading Style Sheets, Lecture notes of Computer Science

Toggle sidebar
bg1
Introduction to Web
Technology
UNIT 4
CSS
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download CSS: Styling Web Pages with Cascading Style Sheets and more Lecture notes Computer Science in PDF only on Docsity!

Introduction to Web

Technology

UNIT 4

CSS

Introduction

 (^) CSS stands for C ascading S tyle S heets  (^) CSS describes how HTML elements are to be displayed on screen, paper, or in other media  (^) CSS saves a lot of work.  (^) It can control the layout of multiple web pages all at once  (^) External stylesheets are stored in CSS files  (^) 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 Selectors

The element selector - CSS selectors are used to "find" (or select) HTML elements based on their element name, id, class, attribute, and more. The element selector selects elements based on the element name. You can select all

elements on a page like this (in this case, all

elements will be center- aligned, with a red text color): Example p { text-align: center; color: red; }

## CSS Selectors

The id Selector –

The id selector uses the id attribute of an HTML element to select a specific element. The id of an element should be unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element. The style rule below will be applied to the HTML element with id="para1": Example #para1 { text-align: center; color: red; }

CSS Selectors

Grouping selectors – If you have elements with the same style definitions, like this: h1 { text-align: center; color: red; } h2 { text-align: center; color: red; } p { text-align: center; color: red; }

CSS Selectors

Grouping Selector –

It will be better to group the selectors, to minimize the code. To group selectors, separate each selector with a comma. In the example above we have grouped the selectors : Example h1, h2, p { text-align: center; color: red; }

Style Sheets Types

There are three ways of inserting a style sheet:

 External style sheet

 Internal style sheet

 Inline style

External Style Sheet

With an external style sheet, you can change the look of an entire website by changing just one

file! Each page must include a reference to the external style sheet file inside the element.

The element goes inside the section:

Example

This is a heading

This is a paragraph.

Internal Style Sheet

An internal style sheet may be used if one single page has a unique style. Internal styles are defined within the

Inline Styles

An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property. The example below shows how to change the color and the left margin of a element: Example This is a heading N0te: An inline style loses many of the advantages of a style sheet (by mixing content with presentation).

CSS Colour , Font , Border and

Margin

The CSS color property defines the text color to be used. The CSS font-family property defines the font to be used. The CSS font-size property defines the text size to be used. The CSS border property defines a border around an HTML element: The CSS margin property defines a margin (space) outside the border:

CSS

CSS3 is the latest version of CSS released in the year 2005.

For responsive web designing, it supports media queries

New Web browsers support CSS3.

CSS3 is backwards compatible even with CSS.

CSS3 provides a different gradient colour and schemes like RGBA, HSLA, HSL,

and other colour gradients.

CSS3 incorporates a new feature where it can group CSS codes into

convenient modules. Modules ensure that all styles for a specific component

will reside in one place.

Features CSS CSS Compatibility The primary purpose of CSS was to focus on formatting features. They have capabilities for positioning texts and objects. CSS is backward compatible with CSS3. When CSS3 code is written in CSS, it is invalid. CSS3 makes the Web Pages more attractive. It takes less time to create a page. Design CSS does not support responsive design. CSS3 is the latest version and supports the responsive design. Modules CSS is not divided into modules. CSS3 could split into modules. Animation CSS cannot produce 3D animation and transformation. In CSS3, the animation and 3D transformations are used. Elements are moved across the screen with the assistance of JavaScript and flash. By using the elements, also be ready to change the size and color. All kinds of transformations and animations are performed by using CSS3. Rounded corners and gradient When CSS3 was launched, the developers designed some images that looked like the rounded corners with the structures and backgrounds. Developers are designing a border and uploading the design to the server. In CSS3 the developer writes the code like: round border {border-radius: 20px}. They have not been sent by any server and perform any other activities. Gradients will also be set by using the code which is given below: gradBG {Background:linear-gradient(red,black);} Text Effects and Text Animations In CSS, animations are written in JavaScript and JQuery. It has not to design layer features and page elements. It had no special effects such as shadowing text, text animation, etc. In CSS3, the developer adds text-shadows to make it easy and effective. They add words for the visual effects of the break line and a comfortable fit inside the column. It changes the size and color of the text. Capacity CSS is slower. CSS3 is faster than CSS. Color CSS provides unique color schemas and standard color. CSS3 supports HSL RGBA, HSLA and the gradient colors.

Features CSS CSS Blocks Multi-column text blocks are defined in CSS3. CSS supports single text blocks. Lists 1.CSS allows a user to:It set different lists for ordered lists 2.CSS set an image for a list item marker 3.CSS add background colors to the list and list items. Some list item markers are : list-style-type. These can be set circle, square, etc. In CSS3, The list item has a counter and affected by counter increment and counter reset properties. In CSS if we use list in CSS3 the ' display ' property must have a list defined in it. CSS3 cannot support a numbering system. The list style image property enables an image is set against the style type marker. It will set as inside the box or outside the box.