What are Cascading Stylesheets (CSS)?

Slides:



Advertisements
Similar presentations
1 © Netskills Quality Internet Training, University of Newcastle Introducing Cascading Style Sheets © Netskills, Quality Internet.
Advertisements

Intro To Cascading Style Sheets By Mario Yannakakis.
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS Cascading Style Sheets. Contents{ 1. What is CSS? 1. A Brief History of CSS 2. Why to use Styles? 2. Syntax 3. Cascading Order 4. Examples of Properties.
CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style.
Cascading Style Sheets
Cascading Style Sheets
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
กระบวนวิชา 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.
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.
4.01 Cascading Style Sheets
Computing Concepts: CSS. Aims  To understand the uses of css  To understand the different types of css  To be able to create a css file  To be able.
Using Cascading Style Sheets (CSS) Dept. of Computer Science and Computer Information CSCI N-100.
Review HTML  What is HTML?  HTML is a language for describing web pages.  HTML stands for Hyper Text Markup Language  HTML is not a programming language,
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
CSS Style Rules Guang Tong, Zhan L;lo’p[ Css Style Rule Guang Tong Zhan Three ways to insert CSS 1 External style sheet 2 Internal style sheet 3 Inline.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
INTRODUCTION TO CSS. OBJECTIVES: D EFINE WHAT CSS IS. K NOW THE HISTORY OF CSS. K NOW THE REASON WHY CSS IS USED. CSS SYNTAX. CSS ID AND CLASS.
CSS Basic (cascading style sheets)
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
IS1825: Developing Multimedia Applications for Business Lecture 1: Introduction to CSS Rob Gleasure
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
DIV, Span, CSS.
Cascading Style Sheets CSS. Source W3Schools
Designing Web Pages The case for CSS. The Power of CSS css Zen Garden
How to… Cascading Style Sheets. How to Insert a Style Sheet When a browser reads a style sheet, it will format the document according to it. There are.
CSS Syntax. Syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property: value}
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
CSS DHS Web Design. Location Between the & Start with – End with –
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
Cascading Style Sheets Using HTML. What are they? A set of style rules that tell the web browser how to present a web page or document. In earlier versions.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
1 Cascading Style Sheets
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
CSS.
Cascading Style Sheets
Cascading Style Sheet.
CSS Cascading Style Sheets
4.01 Cascading Style Sheets
Introduction to CSS.
Introduction to the Internet
CX Introduction to Web Programming
Cascading Style Sheets (CSS)
Introduction to Web programming
Cascading Style Sheet (CSS)
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Cascading Style Sheets - Building a stylesheet
Introduction to CSS.
Cascading Style Sheets
DynamicHTML Cascading Style Sheet Internet Technology.
Introduction to Cascading Style Sheets (CSS)
محمد احمدی نیا CSS محمد احمدی نیا
Web Programming– UFCFB Lecture 11
DynamicHTML Cascading Style Sheet Internet Technology.
Web Design and Development
Made By : Lavish Chauhan & Abhay Verma
Cascading Style Sheets
Cascading Style Sheets - Building a stylesheet
4.01 Cascading Style Sheets
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

What are Cascading Stylesheets (CSS)?

The Three Layers of the Web

What are CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements on a web page Styles are normally stored in style sheets (internal or external) External style sheets can save you a lot of work External style sheets are stored in CSS files 3

Use <style> tag within web pages to define internal styles. Use <link> tag for external style sheets. External style sheets enable you to change the appearance and layout of all the pages in your website CSS separate the document's presentation layout from content of HTML documents. 4

Why use CSS to separate content from presentation? The aim for web developers is to remove all presentation from the HTML code, leaving it clean and semantically correct. 5

Advantages of CSS Less code on page – smaller files and quicker download Easier to make site-wide changes – just change one CSS file Easier and quicker to update/ maintain pages CSS is very powerful – can implement wide variety of formats and layouts Can use different style sheets for different media

Advantages of CSS CSS essential component of Web Standards. Meeting Web Standards mean: More likely that your web pages will look similar in all browsers – and all devices More accessible to users with disabilities More likely to be found by search engines Allows users to customise web pages for their own needs - style switchers – ie. changing in font size More control over code - can deliver code in preferred order for screen readers

Presentation code included in HTML code of all pages 8

Presentation in external CSS file 9

External CSS files for modern browsers, printers and older browsers 10

Cascading Order Multiple style definitions will cascade into one What style will be used when there is more than one style specified for an HTML element? All the styles will ‘cascade’ into a new ‘virtual’ style sheet in the order below (where number four has the highest priority): Browser default External style sheet Internal style sheet (inside the <head> tag) Inline style (inside HTML element)

CSS Syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property: value} The selector is normally the element/tag you wish to define, the property is the attribute you wish to change, and each property must take a value. The property and value are separated by a colon and surrounded by curly braces: body {color: black}

If  the value is multiple words, put quotes around the value: p {font-family: "sans serif"} If you wish to specify more than one property, you should separate each property with a semi-colon: p {text-align: center; color: red}

To make the style definitions more readable, you can describe one property on each line: p { text-align: center; color: black; font-family: arial }

Grouping Selectors You can group selectors. Separate each selector with a comma. For example, each header element will be green: h1, h2, h3, h4, h5, h6 { color: green }

The Class Selector Allows you to define different styles for the same element. For two types of paragraphs in your document: one right-aligned paragraph, and one centre-aligned paragraph: p.right {text-align: right} p.center {text-align: center}

You have to use the class attribute in your HTML document: <p class="right"> This paragraph will be right-aligned. </p>  <p class="center"> This paragraph will be center-aligned. </p>

You can also omit the tag name in the selector to define a style that can be used by many elements: .center {text-align: center}

Below, both the h1 element and the p element are classed with "center". Both of the elements will follow the rules in the ".center" selector:   <h1 class="center"> This heading will be center-aligned </h1> <p class="center"> This paragraph will also be center-aligned. </p>

The id Selector A class selector may apply to SEVERAL elements on a page An id selector can only apply to ONE element

This style will be applied to a p element that has the id value “para1”: { font-size: 100%; font-weight: bold; color: #0000ff; background-colr: transparent }

CSS Comments A comment will be ignored by the browser. A CSS comment begins with "/*", and ends with "*/", like this: /* This is a comment */ p { text-align: center; /* This is another comment */ color: black; font-family: arial }

How to Insert a Style Sheet External style sheet Internal style sheet Inline styles

External Style Sheet Each web page must be linked to the style sheet using the <link> tag. The <link> tag goes inside the head section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> The browser will read the styles from the file mystyle.css, and format the document accordingly.

External Style Sheet Can be written in any text editor. Should not contain any HTML tags. Should be saved with a .css extension. An example of a .css file is shown below: hr {color: sienna} p {margin-left: 20px} body {background-image:url("images/back40.gif")}

Internal Style Sheet Define internal styles in the head section by using the <style> tag, like this: <head> <style type="text/css"> hr {color: sienna} p {margin-left: 20px} body {background-image: url("images/back40.gif")} </style> </head>

Inline Styles Loses many of the advantages of style sheets. Use the style attribute in the relevant tag. The style attribute can contain any CSS properties: <p style="color: sienna; margin-left: 20px"> This is a paragraph </p>