1 / 16

Cascading Style Sheets- CSS “Add style to your web pages”

Cascading Style Sheets- CSS “Add style to your web pages”. Devendra Shukla Senior web designer Singsys Pte Ltd. Definition of CSS. CSS stands for Cascading Style Sheets Styles - define how to display HTML elements Styles are normally stored in Style Sheets Definition:

khuyen
Télécharger la présentation

Cascading Style Sheets- CSS “Add style to your web pages”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cascading Style Sheets- CSS “Add style to your web pages” DevendraShuklaSenior web designerSingsysPte Ltd

  2. Definition of CSS • CSS stands for Cascading Style Sheets • Styles - define how to display HTML elements • Styles are normally stored in Style Sheets Definition: Cascading Style Sheets (CSS) – is a style sheet language used for describing the look and formatting of a document written in a markup language. You write CSS rules in elements, and modify properties of those elements such ascolor, background color, width, border, font etc. lay out

  3. CSS Cascading Style Sheets, or CSS, is a style sheet language used on the Web CSS specifications are maintained by the World Wide Web Consortium (W3C) Three versions of CSS exist: CSS1, CSS2, and CSS3

  4. CSS1 The first CSS specification to become an official W3C Recommendation is CSS level 1, published in December 1996. Among its capabilities are support for- • Font properties such as typeface and emphasis • Color of text, backgrounds, and other elements • Text attributes such as spacing between words, letters, and lines of text • Alignment of text, images, tables and other elements • Margin, border, padding, and positioning for most elements • The W3C no longer maintains the CSS 1 Recommendation.

  5. CSS2 CSS level 2 specification was developed by the W3C and published as a recommendation in May 1998. A superset of CSS 1, CSS 2 includes a number of new capabilities like- • Positioning • Visual Formatting • Media Types • Interfaces • z-index • and new font properties such as shadows.

  6. CSS3 Work on CSS level 3 started around the time of publication of the original CSS 2 recommendation. The earliest CSS 3 drafts were published in June 1999 • User Interfaces • Accessibility • Columnar layout • Mobile Devices • Scalable Vector Graphics

  7. Advantages Separation of content from presentation CSS facilitates publication of content in multiple presentation formats basedon nominal parameters. Nominal parameters include explicit user preferences, different web browsers, the type of device being used to view the content (a desktop computer or mobile Internet device), the geographic location of the user and many other variables. Bandwidth A stylesheet, internal or external, specifies the style once for a range of HTML elements selected by class, type or relationship to others. This is much more efficient than repeating style information inline for each occurrence of the element. An external stylesheet is usually stored in the browser cache, and can therefore be used on multiple pages without being reloaded, further reducing data transfer over a network.

  8. Advantages Site-wide consistency When CSS is used effectively, in terms of inheritance and "cascading," a global style sheet can be used to affect and style elements site-wide. If the situation arises that the styling of the elements should need to be changed or adjusted, these changes can be made by editing rules in the global style sheet. Before CSS, this sort of maintenance was more difficult, expensive and time-consuming. CSS Saves a Lot of Work! CSS defines HOW HTML elements are to be displayed. Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!

  9. Syntax of CSS The CSS syntax is made up of 5 parts: Selector Property/value Declaration Declaration block Curly braces

  10. Syntax of CSS

  11. Selector Selectors are used to declare which part of the markup a style applies to, a kind of match expression. 3 types of selectors Tag selectors (body, p, div, a) ID selectors (#wrapper, #sidebar) Class selectors (.content, .menu) *The selector is normally the HTML element you want to style *Selectors should never start with a number, nor should they have spaces in them

  12. ID Selector The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the element with id="wrapper": #wrapper { text-align:center; border:1px solid red; Width: 200px; Height: 100px } For example, to identify a paragraph as “head”, use the code: <div id=“wrapper”>… </div> *Do NOT start an ID name with a number!

  13. Class Selector The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "." In the example below, all HTML elements with class="center" will be center-aligned: <h1 class="center">Center-aligned heading</h1> <p class="center">Center-aligned paragraph.</p> .center {text-align:center;} <p class="left">Center-aligned paragraph.</p> p.center {text-align:left;} *Do NOT start an ID name with a number!

  14. Property & Value The property is the style attribute you want to change. Each property has a value *Properties are separated from their respective values by colons : *Pairs are separated from each other by semicolons ;

  15. Declaration Definition: Each CSS line that includes property and value *Each declaration consists of a property and a value

  16. Interesting, right? This is just a sneak preview of the full presentation. We hope you like it! To see the rest of it, just click here to view it in full on PowerShow.com. Then, if you’d like, you can also log in to PowerShow.com to download the entire presentation for free.

More Related