Cascading style sheets (CSS)

Slides:



Advertisements
Similar presentations
Intro To Cascading Style Sheets By Mario Yannakakis.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets
Today CSS HTML A project.
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.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
CSS(Cascading Style Sheets )
กระบวนวิชา 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.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
4.01 Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
CSS Dvijesh Bhatt.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
The Characteristics of CSS
Cascading Style Sheet (CSS)
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
Doman’s Sections Information in this presentation includes text and images from
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.
To Proudly supported by ferrycake.com. We will be printing Cash for your Community tokens every week in the Carmarthen Journal and Llanelli Star. The.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 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.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
CSS Basic (cascading style sheets)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
DIV, Span, CSS.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Introduction To CSS by: Alexandra Vlachakis Sandy Creek High School, Fayette County Schools Content and Resources Used With Permission: Interact With Web.
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.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
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.
Introduction To CSS. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
CSS.
4.01 Cascading Style Sheets
>> Introduction to CSS
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Web Programming– UFCFB Lecture 11
4.01 Cascading Style Sheets
Cascading Style Sheets III B. Com (Paper - VI) & III B
Web Programming and Design
Introduction to Cascading Style Sheets (CSS)
Presentation transcript:

Cascading style sheets (CSS) Carlos A. TIJERINA IBARRA

History of css Cascading Style Sheets were developed as a means for creating a consistent approach to providing style information for web documents. In 1994, nine style sheet languages were proposed to the World Wide Web Consortium (W3C) to improve web presentation capabilities. Of the nine proposals, two were chosen as the foundation for what became CSS: Cascading HTML Style Sheets (CHSS) proposed by Håkon Wium Lie, and Stream- based Style Sheet Proposal (SSP) proposed by Bert Bos. CSS1 was published in 1996, CSS2 in 1997, and CSS3 in 1998. There is no single CSS4 specification, but there are ‘level 4’ modules. World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web.

What is css? Definition Cascading Style Sheets (CSS) – is a rule based language that applies styling to your HTML elements. You write CSS rules in elements, and modify properties of those elements such as color, background color, width, border thickness, font size, etc. Basically, it defines how to display HTML elements.

Benefits of using css Separates structure from presentation Provides advanced control of presentation Easy maintenance of multiple pages Faster page loading Better accessibility for disabled users Easy to learn

Html without css Without CSS, HTML elements typically flow from top to bottom of the page and position themselves to the left by default. With CSS help, we can create containers or DIVs to better organize content and make a Web page visually appealing. HTML = Structure, CSS = style

CSS & The box model CSS works on the box model. A typical Web page consists of many boxes joined together from top to bottom. These boxes can be stacked, nested, and can float. In the picture, there are 4 boxes (from top to bottom): Header, Navigation, Content, Footer.

Typical web page LAYOUT (BOX MODEL)

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

selector Definition: Identifies the HTML elements that the rule will be applied to, identified by the actual element name, e.g. <body>, or by other means such as class attribute values. In other words, the selector is the HTML element you want to style. Example:

Property & value Definition: 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 of properties are separated from each other by semicolons ( ; )

Declaration & Declaration block Declaration Definition: Each CSS line that includes property and value. Each declaration consists of a property and a value. Declaration block: Multiple declaration lines including the curly braces.

Curly braces Definition: The curly braces contain the properties of the element you want to manipulate, and the values that you want to change them to. The curly braces plus their content is called a declaration block.

Class & id selectors In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class". id - 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 = “example": #example {text-align:center; color:red;}

Class & id selectors Class - 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 any 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: .center {text-align:center;}

Attaching a css style sheet to a webpage You can attach a style sheet to a page by adding the code to the <head> section of the HTML page. There are 3 ways to attach CSS to a page: Inline style sheet* Internal style sheet External style sheet

Inline style sheet* Applies styles directly to the elements by adding declarations into the style. CSS is not attached in the <header> but is used directly within HTML tags. For Example: <p style=“color: red;”> This is a simple paragraph and the inline style makes it red.</p>

Internal style sheet Applies styles to HTML by placing the CSS rules inside the tag <style> inside the document tag <head>. Best used to control styling on one page. For Example: <head> <title>my page</title> <style type=“text/css”>p{color:red}</style> </head> <body> <p>this is a simple paragraph</p> </body>

External style sheet Applies styles as a separate file with a .css extension. The file is then referenced from inside the <head> element by a link to the file. You can create an external style sheet in your text editor. Best used to control styling on multiple pages. For Example: <head> <title>my external style sheet page</title> <link rel=“style sheet” type=“text/css” href=“my-external- stylesheet.css”> </head> <body> <p>this is a simple paragraph</p> </body>

Which style sheet is the best option? Web developers rarely use inline CSS. Since they prefer to not mix content with presentation. And it is not efficient since you have to declare the style individually for every component. Internal and External style sheets are more popular because you can style multiple elements with one rule. External style sheets are the best ones because they allow you to save all the style information on a separate file from the content. You can then modify a style for a site and it will update all of the pages in a site.

Colors & formatting in css KEYWORDS Using the keywords like: red, fuchsia, yellow, blue, green you can specify what color you would like the CSS rule to display. There are 17 of these keyword colors you can use in CSS. HEXADECIMAL VALUES Hex values are the most common way of specifying colors for web pages. For example: p{color: #000000;} They can represent a total of 96 colors (16 values times 6 slots).

Colors & formatting in css RGB (RED GREEN BLUE) It has the possibility of 256 colors for each (16x16) (R)256 x (G)256 x (B)256 = 16,777,216 or 16.7 million color values You can specify RGB in either whole numbers or percentages CSS example: h1{color: rgb(0,0,0) } HSL - Hue Saturation Lightness Similar to RGB but based on saturation and lightness of a color CSS example: h1{color: hsl(0,100%,40%) } HSL accepts a number between 0 to 360 in value, it also accepts percentage between 0- 100%

Common css layout properties Width & Height: They can be specified in pixels, ems, percentages or set to auto. Float: It makes elements float to the right or left of the screen, positioned where they are in the HTML. Clear: When elements are floated, they wrap around each other to form a “caravan.” The clear property detaches an element from the “caravan” and allows it to start on a new line. Border: You can define the entire border or only the top, bottom, left, or right. You can also define the border using one declaration. Padding: The space between the text/content and the border. You can use padding for all around the element or specify each side of the rectangle separately. Margin: The space outside the text/content and the border. You can use margin for all around the element or specify each side of the rectangle separately.

Text properties <h3 class=“mainHeading”>Main Heading</h3> .mainHeading { color: red; letter-spacing: 5px; text-transform: uppercase; word-spacing: 15px; text-align: left; font-family: Times; text-decoration: underline; font-size: 12px; font-style: italic; font-weight: bold; } <h3 class=“mainHeading”>Main Heading</h3>

Other visual properties of css Styling Links: The links property defines how inactive, hovered, active, and visited link states appear to the user. Layering: Background colors and images are layered like sheets of paper one on top of the other. Background – Image: The background-image property sets an image in the background of an element. Background – Repeat: The background-repeat property sets an image in the background of an element and tiles, or repeats, it. Tiling is the default. Image Positioning: The background-position property positions the image using either combined keywords (top, bottom, left, right, and center); length values; or percentage values.

Inheritance in css Inheritance is the process by which CSS properties applied to one tag are passed on to nested tags. For example, the paragraph tag will inherit the same styling as the body tag because <p> is always located inside <body>. <body style=“font-family: Arial”> <p>This text will be Arial as well</p> </body> So, instead of styling each paragraph separately, you can define the font color in the <body>, and everything inside will have that color.

resources http://w3schools.com/css/ http://www.csszengarden.com/ http://w3schools.com/cssref/default.asp http://en.wikipedia.org/wiki/Cascading_Style_Sheets

assignment Create at least two HTML-based web pages with the same content and structure, but with different styles defined with CSS. Reference: http://w3schools.com/css/demo_default.htm Submit your assignment in class or to catijerniaibarra@utpa.edu