( Cascading style sheet )

Slides:



Advertisements
Similar presentations
LIS901N: Style sheet Thomas Krichel Style sheets Style sheets are the officially sanctioned way to add style to your document We will cover.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Web Engineering 1 Ishaq Khan Shinwari MCS City University Peshawar.
Cascading Style Sheets
Cascading Style Sheets
CSS CSS stands for Cascading Style Sheets Styles define how to display HTML elements External Style Sheets can save a lot of work External Style Sheets.
Cascading Style Sheets (CSS): Pixel-Level Control with HTML Ease
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
Client-Side Internet and Web Programming
CSS(Cascading Style Sheets )
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Measurement Many CSS properties (values within the declaration) require that you specify a unit of measurement, such as spacing between elements, border.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
More CSS CS HTML id attribute 2 Coding Horror! Our mission is to combine programming and “human” factors with geekiness! output  A unique ID for.
Style sheets can also affect the BODY. style4.css BODY {BACKGROUND-COLOR : white} H1 {COLOR : red; FONT-SIZE : 50; FONT-FAMILY : arial} H2 {COLOR : green}
Style sheets can also affect the body. style4.css body {background-color : white} h1 {color : red; font-size : 50; font-family : arial} h2 {color : green}
4.01 Cascading Style Sheets
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CSS Border.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
WebD Introduction to CSS By Manik Rastogi.
CSS.
IS1500: Introduction to Web Development
Chapter 6 - Cascading Style Sheets™ (CSS)
CS3220 Web and Internet Programming CSS Basics
Cascading Style Sheets™ (CSS)
4.01 Cascading Style Sheets
Semester - Review.
Unit 3 - Review.
Creating Your Own Webpage
UNIT-II CSS.
Introduction to the Internet
>> The “Box” Model
Madam Hazwani binti Rahmat
Cascading Style Sheets
Cascading Style Sheets (Formatting)
Cascading Style Sheet (CSS)
Web Systems & Technologies
CSS Applications to XML 19-Sep-18.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets
The Internet 10/13/11 The Box Model
CSS Borders and Margins.
Second CSS Lecture Applications to XML
CSS Style Sheets: Intro
Cascading Style Sheets Color and Font Properties
Cascading Style Sheets™ (CSS)
How to use the CSS box model for spacing, borders, and backgrounds
More CSS 22-Feb-19.
CS3220 Web and Internet Programming CSS Basics
CS3220 Web and Internet Programming CSS Basics
Cascading Style sheet. What is CSS?  CSS stands for Cascading Style Sheets  Cascading: refers to the procedure that determines which style will apply.
Cascading Style Sheets
4.01 Cascading Style Sheets
CSS Applications to XML 20-May-19.
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
CSS Applications to XML 3-Jul-19.
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
CGS 3066: Web Programming and Design Fall 2019
Cascading Style Sheets
Presentation transcript:

( Cascading style sheet ) Chapter#3 CSS ( Cascading style sheet )

Cascading Style Sheets (CSS) Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML.

Cont.… A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block. A declaration-block consists of a list of declarations in braces. Each declaration itself consists of a property, a colon (:), and a value. If there are multiple declarations in a block, a semi-colon (;) must be inserted to separate each declaration.

Cont.…

Cont.… Inline styles, inside the HTML document, style information on a single element, specified using the style attribute Embedded or internal style, blocks of CSS information inside the <head> element of HTML itself External style sheets, i.e., a separate CSS file referenced from the document

Example : The following example demonstrates the inline style <!doctype html> <html> <body> <p style=”font-family:arial;color:blue;font-size:medium”> This is a paragraph formatted with inline css style. </p> </body> </html>

Example : The following example demonstrates the internal style <!doctype html> <html> <head> <style> P { Font-family:arial; Font-size:medium; Color:blue; Text-align:justify; } </style> </head> <body> <p> This is a paragraph formatted with internal css style. </p> </body> </html>

Example The following example demonstrates the external style. Create a new document in notepad, define the following css styles within it and save it with the name Style.css P { Font-family:arial; Font-size:medium; Color:blue; Text-align:justify; } H1 Font-family:arial black; Background-color:blue; Color:white;

Cont.… Create another new document in notepad and create a html file with the following html markup. To link an external css file, use <link> element of html within the <head> element. <!doctype html> <html> <head> <link rel=”stylesheet” type=”text/css” href=”MyStyle.css”/> </head> <body> <h1> Heading </h1> <p> This is a paragraph formatted with internal css style. </p> </body> </html>

CSS Colors Colors in CSS are most often specified by: 1. a valid color name - like "red" 2. an RGB value - like "rgb(255, 0, 0)" 3. a HEX value - like "#ff0000"

Color Names Color Name Red Green Blue Orange Yellow Cyan Black   Red Green Blue Orange Yellow Cyan Black Note: Color names are case-insensitive: "Red" is the same as "red" or "RED".

RGB (Red, Green, Blue) RGB color values can be specified using this formula: rgb(red, green, blue). Each parameter (red, green, blue) defines the intensity of the color between 0 and 255. Color RGB   rgb(255,0,0) rgb(0,255,0) rgb(0,0,255) rgb(255,165,0) rgb(255,255,0) rgb(0,255,255)

Cont.… Color RGB   rgb(0,0,0) rgb(128,128,128) rgb(255,255,255)

Hexadecimal Colors RGB values can also be specified using hexadecimal color values in the form: #RRGGBB, where RR (red), GG (green) and BB (blue) are hexadecimal values between 00 and FF (same as decimal 0-255).

CSS Backgrounds

Background Color The background-color property specifies the background color of an element. The background color of a page is set like this: Example: body {     background-color: lightblue; } h1 {     background-color: green; } div {     background-color: lightblue; } p {     background-color: yellow; }

Background Image The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. Example body { background-image: url("paper.gif"); }

Background Image - Repeat Horizontally or Vertically This example shows us that how we will repeat the background image horizontally. body { background-image: url("gradient_bg.png"); background-repeat: repeat-x; } This example shows us that how we will repeat the background image vertically. body { background-image: url("gradient_bg.png"); background-repeat: repeat-y; }

Set position and no-repeat body {     background-image: url("img_tree.png");     background-repeat: no-repeat;     background-position: right top; }

Background Image - Fixed position body { background-image: url("img_tree.png"); background-repeat: no-repeat; background-position: right top; background-attachment: fixed; } We can apply the code by using single line property. body { background: #ffffff url("img_tree.png") no-repeat right top; }

CSS Height and Width Dimensions: Note: The CSS dimension properties allow you to control the height and width of an element. This element has a width of 100%.

Setting height and width The height and width properties are used to set the height and width of an element. The height and width can be set to auto (this is default. Means that the browser calculates the height and width), or be specified in length values, like px, cm, etc., or in percent (%) of the containing block.

Cont… This <div> element has a height of 100 pixels and a width of 500 pixels. Example: div { width: 500px; height: 100px; border: 3px solid blue; }

CSS Borders

Border-Style The following values are use for border-style. dotted - Defines a dotted border Dashed - Defines a dashed border Solid - Defines a solid border double - Defines a double border Groove - Defines a 3D grooved border. The effect depends on the border-color value ridge - Defines a 3D ridged border. The effect depends on the border-color value Inset - Defines a 3D inset border. The effect depends on the border-color value Outset - Defines a 3D outset border. The effect depends on the border-color value None - Defines no border Hidden - Defines a hidden border

Example p.dotted {border-style: dotted;} p.dashed {border-style: dashed;} p.solid {border-style: solid;} p.double {border-style: double;} p.groove {border-style: groove;} p.ridge {border-style: ridge;} p.inset {border-style: inset;} p.outset {border-style: outset;} p.none {border-style: none;} p.hidden {border-style: hidden;} p.mix {border-style: dotted dashed solid double;}

Result:

Border Width Border-width has three values: Thin Medium Thick Example: border-style:solid; border-width:thin; } border-width:medium; border-width:thick;

Border Color Border-color property sets the color of the border on its edges p { border-style: solid; border-color: red; }

Border - Individual Sides We can give style to each side of border individually by using the following properties. p { border-top-style: dotted; border-right-style: solid; border-bottom-style: dotted; border-left-style: solid; }

Border Shorthand property Here we have single line property to set the border including border-width, border-style, border-color. p { border: 1px solid red; }

CSS Margins The CSS margin properties set the size of the white space OUTSIDE the border. Margin pull the web object to a specified direction

Margin - Individual Sides Example: p {     margin-top: 100px;     margin-bottom: 100px;     margin-right: 150px;     margin-left: 80px; } margin-top margin-right margin-bottom margin-left

Margin - Shorthand Property The margin property is a shorthand property for the following individual margin properties: margin-top margin-right margin-bottom margin-left Example p {     margin: 100px 150px 100px 80px; }

CSS Padding Properties The CSS padding properties are used to generate space around content. The padding properties set the size of the white space between the element content and the element border.

Padding - Individual Sides CSS has properties for specifying the padding for each side of an element: padding-top padding-right padding-bottom padding-left All the padding properties can have the following values: length - specifies a padding in px, pt, cm, etc. % - specifies a padding in % of the width of the containing element.

Example p {     padding-top: 50px;     padding-right: 30px;     padding-bottom: 50px;     padding-left: 80px; }

Padding - Shorthand Property To shorten the code, it is possible to specify all the padding properties in one property. The padding property is a shorthand property for the following individual padding properties: padding-top padding-right padding-bottom padding-left Example p {     padding: 50px 30px 50px 80px; }

Padding formats padding: 25px 50px 75px 100px; top padding is 25px right padding is 50px bottom padding is 75px left padding is 100px If the padding property has three values: padding: 25px 50px 75px; right and left paddings are 50px If the padding property has two values: padding: 25px 50px; top and bottom paddings are 25px right and left paddings are 50px If the padding property has one value: padding: 25px; all four paddings are 25px

CSS Text

Css text formatting Text Color: The color property is used to set the color of the text. Text Alignment: The text-align property is used to set the horizontal alignment of a text. A text can be left or right aligned, centered, or justified. Text Decoration: The text-decoration property is used to set or remove decorations from text. The value text-decoration: none; is often used to remove underlines from links: Text Transformation: The text-transform property is used to specify uppercase and lowercase letters in a text.

Css text formatting Text Indentation The text-indent property is used to specify the indentation of the first line of a text: Letter Spacing The letter-spacing property is used to specify the space between the characters in a text. Word Spacing The word-spacing property is used to specify the space between the words in a text. Line Height The line-height property is used to specify the space between lines:

Example h1 { color: green; text-align: center/left/right; text-align: justify; text-decoration: overline/underline/line-through; Text-transform: uppercase/lowercase/capitalize; text-indent: 50px; letter-spacing: 3px; line-height: 1.8; word-spacing: 10px; }

Css fonts

Css fonts Font Family The font family of a text is set with the font-family property. The font-family property should hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font, and so on. Font Style The font-style property is mostly used to specify italic text. Font Size The font-size property sets the size of the text. Font Weight The font-weight property specifies the weight of a font:

Example p { font-family: "Times New Roman", Times, serif; font-style: normal/italic/oblique; font-size: 40px/em/%; font-weight: normal/bold/value in px; }

CSS Layout - The display Property