CGS 3066: Web Programming and Design Fall 2019

Slides:



Advertisements
Similar presentations
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
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.
Introduction to CSS.
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.
4.01 Cascading Style Sheets
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
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.
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.
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.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS Cascading Style Sheets *referenced from
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
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.
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.
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.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheets
Cascading Style Sheet.
CSS Cascading Style Sheets
Cascading Style Sheets™ (CSS)
4.01 Cascading Style Sheets
( Cascading style sheet )
CSS Rule Selector Declaration Block Value Attribute Name body {
>> Introduction to CSS
Introduction to CSS.
Introduction to the Internet
Chapter 6 Cascading Style Sheets™ (CSS)
Using Cascading Style Sheets Module B: CSS Structure
Cascading Style Sheets
Intro to CSS CS 1150 Fall 2016.
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.
Intro to CSS CS 1150 Spring 2017.
Software Engineering for Internet Applications
Cascading Style Sheets
DynamicHTML Cascading Style Sheet Internet Technology.
محمد احمدی نیا CSS محمد احمدی نیا
Web Programming– UFCFB Lecture 11
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets™ (CSS)
DynamicHTML Cascading Style Sheet Internet Technology.
Tutorial 3 Working with Cascading Style Sheets
Introduction to CSS.
Web Design & Development
Cascading Style Sheets
Cascading Style Sheets - Building a stylesheet
Cascading Style Sheets
4.01 Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Cascading Style Sheets III B. Com (Paper - VI) & III B
Cascading Style Sheets™ (CSS)
Cascading Style Sheets
Presentation transcript:

CGS 3066: Web Programming and Design Fall 2019 Department of Computer Science, Florida State University

Introduction to CSS Stands for Cascading Style Sheets Current version: CSS 3 Defines how to display HTML elements Focus on presentation of given contents Content Layout Advanced Text Formatting Color Scheme Borders and Spacing etc.

Why CSS? The original purpose of HTML was to combine the structure and content of the page into one document. When presentation elements began to be included in the document, it increased the complexity and reduced readability. Solution: Move the presentation elements elsewhere.

Why CSS? Separate the “style” elements from the documents and put it in a “style sheet”. Advantages: Styles can be changed easily. Document is more readable.

3 ways to do styling Inline Style style as an HTML element attribute Internal Style Sheets A <style> tag is used in the HTML document to specify the presentation elements. External Style Sheets A separate “.css” file is used as a part of your set of documents. It contains all the styling elements.

Inline CSS Use “style” attribute at any HTML element Mixes content with presentation. Loses many of the advantages of a style sheet. Used very rarely (when very few elements require styling).

Inline CSS example <h1 style="color:blue;margin-left:30px;"> This is a heading.</h1>

Internal CSS Used when the current document has a unique style. A <style> tag is used under the <head> tag of the document to define the styles. The content of the <style> tag follows CSS syntax.

Internal CSS example <head> <style> body { background-color: linen; } h1 { color: maroon; margin-left: 40px; </style> </head>

External CSS Used when a style is applied to many pages The look of the webpage can be changed by just changing one file. Each page must include a link to the style sheet with the <link> tag. The <link> tag goes inside the head section.

External CSS An external stylesheet is written as a separate file with a “.css” extension. Should go into the same relative path as the rest of the files (or can be referred by absolute path). The external stylesheet should not contain any HTML tags.

External CSS example mystyle.css body { background-color: seagreen; } h1 { color: black; margin-left: 20px;

External CSS example <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>

Cascading Order Inline style attributes Internal <style> Multiple style definitions ‘cascade’ into the resultant style Styles for a same HTML element may be declared differently in different contexts resulting conflicts resolved through ordering Order of application of CSS rules(highest -> lowest priority) Inline style attributes Internal <style> External stylesheet (.css) Browser Default

CSS Specificity IDs Class attributes Element type When multiple style rules from same cascading order(i.e. 2 rules at .css) try to modify the same element, the order of specificity applies If two selectors apply to the same element, the one with higher specificity wins. Inline style do not face this issue, retains highest specificity Decreasing order o Specificity In Internal/external CSS: IDs Class attributes Element type In case of two equally specific rules, the latest rule applies

CSS Syntax A CSS file contains one or more rule-sets (or simply rules) A rule-set describes presentation style for a particular part of the HTML document. For example, a rule-set to color all <h1> headings blue and set font size to 12 : h1 { color: blue; font-size: 12px; }

CSS Rule Set The declaration block is enclosed in { }. The declaration block contains one or more declarations separated by semicolons. Each declaration includes a property name and a value, separated by a colon. To make the CSS code more readable, you can put one declaration on each line. Source: http://www.w3schools.com/css/css_syntax.asp

CSS Selectors Selects the set of HTML elements over which a rule-set is applied Used to "find" HTML elements based on id, classes, types, attributes, values of attributes, etc. Typically, selectors are one of 3 kinds: id selector element selector class selector

Element Selector The element selector selects elements based on the element name. Applied to all elements with the same name (tag) p { text-align: center; color: red; }

ID Selector The id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page. To find an element with a specific id, write a hash character, followed by the id of the element. #para1 { text-align: center; color: red; }

Class Selector The class selector finds elements with the specific class. The class selector uses the HTML class attribute. To find elements with a specific class, write a period character, followed by the name of the class. .center { text-align: center; color: red; }

Class Selector You can also specify that only specific HTML elements should be affected by a class. p.center { text-align:center; color:red; }

Grouping Selectors In style sheets there are often elements with the same style In the interest of code minimization, we can group selectors Selectors are separated by commas. h1, h2, p { text-align: center; color: red; }

CSS3 Declarations As of now, 415 distinct property names on different specification status Latest properties have different level of browser support Learn the most common ones, use reference guide for fine-grained styling

CSS measurement units Frequently used to set values to properties Absolute: in : inches cm : centimeters mm : millimeters px : pixels (1 px = 1/96th of 1in) Relative: em : ratio to the font size of current element % : percentage to the font size of current element

color property and values Applies the color value to the text contents of the selected element(s) Possible color values: predefined color names(e.g. black, blue, purple) p { color: red; } Hexadecimal color codes using 6 character notation p { color: #ff0000; } Red, Green, Blue components in 0-255 scale using rgb() syntax Absolute, 0-255 scale: p{color: rgb(255,0,0)} Relative scale in % : p{color: rgb(100%,0,0)}

CSS Text Formatting Properties text-align : specifies horizontal alignment [left/right/center/justify] text-indent : sets indentation for the first line of the element [in units] text-decoration : used to decorate text [none/underline/overline/line-through] text-transform : controls capitalization [uppercase/lowercase/capitalize] letter-spacing : specifies spacing behavior between characters [in units] word-spacing : specifies spacing behavior between words [in units]

CSS Text Formatting Properties(contd.) font-family: accepts a list of font names separated by comma. Prioritized from left to right and used based on availability. May use font name within double quotes(e.g. “"Lucida console"”) or generic font name [serif/sans-serif/cursive/fantasy/monospace] font-size: specifies size of fonts [in units] font-style : [normal/italic/oblique] font-Weight : [normal/bold /bolder /lighter ]

CSS Background Properties Used to define the background effects of an element. CSS properties used for background effects: background-color: uses color value to set background background-image: set an image as background. Image name accepted in the form: url(“<image name>”) background-repeat: controls image repeats. Common values are repeat-x, repeat-y, repeat, no-repeat etc. background-attachment: sets whether a background image is fixed or scrolls with the rest of the page. [scroll/fixed/local] background-position: sets starting position of a background image. background-size: Specifies the size of the background images.

CSS Comments CSS comments follow the multiline C comment syntax A CSS comment starts with /* and ends with */ Comments can also span multiple lines and are ignored by browsers