Cascade Style Sheet Demo ISYS 350. Cascading Style Sheets Cascading Style Sheets (CSS) is a mechanism for adding style (e.g., fonts, colors, spacing)

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

Cascade Style Sheet Demo ISYS 350. Cascading Style Sheets Cascading Style Sheets (CSS) is a mechanism for adding style (e.g., fonts, colors, spacing)
Cascading Style Sheets
Today CSS HTML A project.
CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
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.
CSS(Cascading Style Sheets )
Cascade Style Sheet Demo. Cascading Style Sheets Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to.
กระบวนวิชา 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.
CSS Cascading Style Sheets Brief Introduction
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
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.
Creating Web Pages with HTML and CSS ISY 475. HTML Introduction History: – Standard.
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.
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,
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
CSS Dvijesh Bhatt.
Cascade Style Sheet Demo ISYS 350. Cascading Style Sheets Cascading Style Sheets (CSS) is a mechanism for adding style (e.g., fonts, colors, spacing)
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.
Cascading style sheets (CSS)
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
The Characteristics of CSS
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
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.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
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 Programming the WWW I CMSC Summer 2004 Lecture 7.
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)
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.
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)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
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.
REEM ALMOTIRI Information Technology Department Majmaah University.
Cascade Style Sheet Demo W3Schools.com: ISYS 350.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Lecture 2: Cascading Style Sheets (CSS) Instructor: Dr. M. Anwar Hossain.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
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.
1 CSS محمد احمدی نیا 2 Of 21 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements 
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.
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.
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.
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 solve a problem External.
1 Cascading Style Sheets
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.
Cascading Style Sheet.
4.01 Cascading Style Sheets
Cascading Style Sheets (Layout)
Cascade Style Sheet Demo W3Schools. com: w3schools
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascade Style Sheet Demo W3Schools. com: w3schools
محمد احمدی نیا CSS محمد احمدی نیا
Cascading Style Sheets
4.01 Cascading Style Sheets
Cascade Style Sheet Demo W3Schools. com: w3schools
Presentation transcript:

Cascade Style Sheet Demo ISYS 350

Cascading Style Sheets Cascading Style Sheets (CSS) is a mechanism for adding style (e.g., fonts, colors, spacing) to Web documents. A style sheet consists of a list of style rules. Each rule or rule-set consists of one or more selectors, and a declaration block.

CSS Rule Syntax A CSS rule has two main parts: a selector, and one or more declarations:

A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets. Example: p { color:red; text-align:center; }

Typical Properties of Style background-color – Color – color:red font – font-family:courier Font-size – font-size:300% text-align – text-align:center

CSS MIME Type Multipurpose Internet Mail Extensions (MIME) is an Internet standard of content type system. CSS MIME type: – text/css Example: referencing a CSS file using the element inside the head section

Three Ways to Insert CSS External style sheet Internal style sheet Inline style

External Style Sheet An external style sheet can be written in any text editor. It should be saved with a.css extension. An external style sheet is ideal when the style is applied to many pages. A web page must link to the style sheet using the tag. The tag goes inside the head section:

Internal Style Sheet An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the tag, like this: hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} Note: Do not add a space between the property value and the unit (such as margin-left:20 px). The correct way is: margin-left:20px

Inline Styles To use inline styles you use the style attribute in the HTML tag. Example: This is a paragraph. An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly!

HTML Element as Selector Apply to all elements of a specific type: – H1 { color: blue; } – p {color:red;text-align:center;}

Example This is h1 text This is h3 text This is h6 text This is h1 text again This is h3 text again This is h6 text again This is the P tag data H1 { color: blue; } H3 {color:green;} H6 {color:red;} p {color:red;text-align:center;} body {background-color:aqua;}

ID as a selector The id selector is used to specify a style for a single, unique element identified by the id attribute of the HTML element. The selector is with a preceding '#': Example: – A HTML element : – The style rule is: #mycontent { width: 450px; margin: 0 auto; padding: 15px; background: white; border: 2px solid navy; }

Class As Selector The class selector is used to specify a style for a group of elements. The class selector uses the HTML class attribute to set a particular style for many HTML elements with the same class. The class selector is defined with a "."

Examples of Class Selector Example 1: All HTML elements with class="center" will be center-aligned: – HTML: Center-aligned heading – Style: with a preceding “.”.center{ text-align:center; } Example 2: In the example below, all p elements with class="center" will be center-aligned: – p.center {text-align:center;}

Example This is h1 text This is h3 text This is h6 text This is h1 text again This is h3 text again This is h6 text again This is the P tag data This is the 2nd P tag data.center{ text-align:center; } p.left{text-align:left;}

The CSS Box Model All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout. The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.

box model

Explanation of the different parts of a box Margin - Clears an area around the border. The margin does not have a background color, it is completely transparent Border - A border that goes around the padding and content. The border is affected by the background color of the box Padding - Clears an area around the content. The padding is affected by the background color of the box Content - The content of the box, where text and images appear

Example width:250px; padding:10px; border:5px solid gray; margin:10px; The total width of the element in the example is 300px: 250px (width) + 20px (left + right padding) + 10px (left + right border) + 20px (left + right margin) = 300px

Example: Define a box for a P tag: p{color:red;text-align:center; width:250px; padding:10px; border:5px solid gray; margin:10px; }

Example: Page View

HTML Code Product Discount Calculator Product Description: List Price: Discount Percent: % Note: The HTML code for a no-break space is.

body { font-family: Arial, Helvetica, sans-serif; margin: 10px; padding: 0; } #mycontent { width: 450px; margin: 0 auto; padding: 15px; background: white; border: 2px solid navy; } h1 { color: navy; } label { width: 10em; padding-right: 1em; float: left; } #mydata input { float: left; width: 15em; margin-bottom:.5em; } #buttons input { float: left; margin-bottom:.5em; } br { clear: left; }

CSS Font-Size: em vs. px vs. pt vs. percent An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt,.5em would equal 6pt, etc. Generally, 1em = 12pt = 16px = 100%

HTML Element Object Properties: className property style property Assuming we have two classes: –.evenColor {color:red;} –.oddColor {color:black;} Example of assigning className value dynamically using code. var row = table.insertRow(rowCount); if(count % 2 == 0){ row.className = "evenColor"; } else{ row.className = "oddColor"; } Example of assigning style property using code: var boxFV=document.getElementById('FV'); fv=myPV*Math.pow(1+myRate,myYear); if (fv>1000) boxFV.style.backgroundColor = "red"; else boxFV.style.backgroundColor = "green";

Loan Affordability Analysis

HTML Code Loan Affordability Analysis Enter Loan: Enter Rate: Enter Term: Enter Affordable payment: Payment is:

computePmt() function computePmt(){ Loan=parseFloat(document.getElementById("Loan").value); Rate=parseFloat(document.getElementById("Rate").value); Term=parseFloat(document.getElementById("Term").value); Afford=parseFloat(document.getElementById("Afford").value); Pmt=(Loan*Rate/12)/(1-Math.pow(1+Rate/12,-12*Term)); var boxPmt=document.getElementById("Pmt"); if (Pmt>Afford) boxPmt.style.backgroundColor="red"; else boxPmt.style.backgroundColor="green"; boxPmt.value=Pmt.toFixed(2); }

CSS File div { width: 450px; margin: 0 auto; padding: 15px; background: aqua; border: 2px solid navy; } p {font-weight:bold;}

Pseudo Class Selector : pseudo-classes are used to add special effects to some selectors. For example, change color when mouse is over the element, a:hover {color:#FF00FF;} table:hover {color:red;} td:hover {color:blue;} p:hover{color:blue;} See list of pseudo-classess such as link, visited, focus, etc.:

function showTable(){ value=eval(document.depForm.pValue.value); life=eval(document.depForm.pLife.value); depreciation = value / life; var table = document.getElementById('depTable'); var totalDepreciation=0; for(var i = table.rows.length - 1; i > 0; i--) { table.deleteRow(i); } for (count = 1; count <= life; count++) { var rowCount = table.rows.length; var row = table.insertRow(rowCount); if(count % 2 == 0){ row.className = "evenColor"; }else{ row.className = "oddColor"; } var cell0 = row.insertCell(0); cell0.innerHTML=count; var cell1 = row.insertCell(1); cell1.innerHTML="$" + value.toFixed(2); var cell2 = row.insertCell(2); cell2.innerHTML="$" + depreciation.toFixed(2); totalDepreciation += depreciation; var cell3 = row.insertCell(3); cell3.innerHTML="$" + totalDepreciation.toFixed(2); value -= depreciation; }

Body Section Straight Line Depreciation Table Enter Property Value: Enter Property Life_: Year Value at BeginYr Dep During Yr Total to EndOfYr

CSS File #content { width: 650px; margin: 0 auto; padding: 15px; background: aqua; border: 2px solid navy; } table:hover {color:blue;} td:hover {color:blue;} table { border:1px solid green; margin: 0 auto; }.evenColor {color:red;}.oddColor {color:black;} p { font-size: 200; font-weight: bold; text-align: center; text-decoration: underline; }

Positioning Elements can be positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. – fixed – relative – absolute #mycontent { position: absolute;left:100px;top:100px; width: 450px; margin: 0 auto; padding: 15px; background: white; border: 2px solid navy; }

Tutorials W3C: – properties properties W3Schools.com: –