CS428 Web Engineering Lecture 06 Introduction (Cascading Style Sheet) 1.

Slides:



Advertisements
Similar presentations
Web Pages Week 10 This week: CSS Next week: CSS – Part 2.
Advertisements

Cascading Style Sheets
1 Pengantar Teknologi Internet W03: 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.
More CSS CS HTML id attribute 2 Coding Horror! Our mission is to combine programming and “human” factors with geekiness! output  A unique ID for.
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
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.
CSS – CASCADING STYLE SHEETS Making your XHTML webpage look good.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
4.01 Cascading Style Sheets
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
INTRO TO WEB DEVELOPMENT
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
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,
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
CSS Dvijesh Bhatt.
LING 408/508: Programming for Linguists
Cascading style sheets (CSS)
Cascading Style Sheet (CSS)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
WORKING WITH CASCADING
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
Website Development & Management Working with Style Rules Instructor: John Seydel, Ph.D. CIT Fall
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
 A style sheet is a single page of formatting instructions that can control the appearance of many HTML pages at once.  If style sheets accomplished.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Cascading Style Sheets (CSS). CSS: A New Philosophy Separate content from presentation! Title Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
IS 360 Declaring CSS Styles. Slide 2 Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
CS 142 Lecture Notes: CSSSlide 1 CSS Rule body { font-family: Tahoma, Arial, sans-serif; color: black; background: white; margin: 8px; } Selector Declaration.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
More css HTML and css 2012 Brian Davison. DIV Use... to mark a division or section of your Web page Lorem ipsum dolor sit amet, consectetur adipiscing.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets Objective: Create an external style sheet, embedded style sheet, and an inline style to change the look and feel of a web site.
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.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
LING 408/508: Programming for Linguists Lecture 10 September 30 th.
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,
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
CSS: Cascading Style Sheets Part II. Style Syntax.
CSS Cascading Style Sheets *referenced from
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.
Agenda Cascading Style Sheets Selectors and Declarations Fonts and Font Families Content Flow Positioning Content Overflow.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
Managing Text Flow by Using CSS
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.
Internet & World Wide Web How to Program, 5/e 1. 2.
4.01 Cascading Style Sheets
CSS Rule Selector Declaration Block Value Attribute Name body {
Chapter 6 Cascading Style Sheets™ (CSS)
CSS Applications to XML 19-Sep-18.
Second CSS Lecture Applications to XML
Software Engineering for Internet Applications
More CSS 22-Feb-19.
Cascading Style Sheets
4.01 Cascading Style Sheets
CSS Applications to XML 20-May-19.
CSS Applications to XML 3-Jul-19.
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

CS428 Web Engineering Lecture 06 Introduction (Cascading Style Sheet) 1

snotes4u/webeng 2

CASCADING STYLE SHEET This is the language to add presentation styling to HTML documents. CSS is a powerful and flexible way to add format to web page for presentation. Through CSS it is relatively easy to take simple page of text and images, formatted to present as fully professional webpage. 3

CSS has a simple syntax, consist of selectors, properties and values it together make a style rules. It gives developer find ways to control over how each element of page is formatted. CSS styles can apply on HTML documents through several different ways. –Create an external CSS file. –Embed CSS code in HTML document. 4

CSS Syntax A style rule is made of three parts: Selector: A selector is an HTML tag at which style will be applied. This could be any tag like or etc. Property: A property is a type of attribute of HTML tag. Put simply, all the HTML attributes are converted into CSS properties. They could be color or border etc. Value: Values are assigned to properties. For example color property can have value either red or #F1F1F1 etc. 5

You can put CSS Style Rule Syntax as follows: selector { property: value; } Example: You can define a table border as follows: table { border: 1px solid #C00FDF; } 6

Applying CSS There are three ways through which you apply CSS on your HTML doc.  Inline  Internal  External 7

Inline CSS You can also embed your CSS code in HTML document. Example: 8

INTERNAL CSS always placed between tags. Example: p { line-height: 120%; } 9

EXTERNAL CSS FILE External CSS file will always place between tags. <link rel=“stylesheet” type=“text/css” href=“main.css” /> 10

CSS Rules Overriding Any inline style sheet takes highest priority. So it will override any rule defined in... tags or rules defined in any external style sheet file. Any rule defined in... tags will override rules defined in any external style sheet file. Any rule defined in external style sheet file takes lowest priority and rules defined in this file will be applied only when above two rules are not applicable. 11

EXAMPLE div { color: #9932CC; } Style Sheets Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sit amet lorem ligula. 12

EXAMPLE a { font-family: sans-serif; } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sit amet lorem ligula. Nam pulvinar nunc ac magna aliquam quis sodales dui elementum. Fusce a lacus leo. 13

SELECTORS There are three types of selectors:  Tag selectors  ID selectors  Class selectors 14

Example Tag Selector p { font-family: sans-serif; font-size: 15pt; line-height: 150%; } 15 Tag selector

Example Class Selector.foo { font-family: sans-serif; font-size: 15pt; line-height: 150%; } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sit amet lorem ligula. Nam pulvinar nunc ac magna aliquam quis sodales dui elementum. Fusce a lacus leo. Maecenas ut dui eu quam condimentum sagittis. 16 class selector

Example Class Selector p.foo { font-family: sans-serif; font-size: 15pt; line-height: 150%; } 17 class selector

Example ID Selector #p1 { font-family: sans-serif; font-size: 15pt; line-height: 150%; } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sit amet lorem ligula. Nam pulvinar nunc ac magna aliquam quis sodales dui elementum. Fusce a lacus leo. Maecenas ut dui eu quam condimentum sagittis. 18 ID selector

RULE for ID selector There is only be one element in a document with a particular ID selector. ID selector can only be used once in one element/tag. 19

Descendant Selector p a { font-family: sans-serif; font-size: 15pt; line-height: 150%; } Lorem ipsum dolor sit amet, consectetur adipiscing elit.. Nam pulvinar nunc ac magna aliquam quis sodales dui nunc sit elementum. Donec eu nisi turpis, sit amet rutrum leo. Click here 20

Grouping Selector you can apply style to many selectors. h1, p, section { color: #35c; font-weight: bold; letter-spacing:.4em; } 21

Grouping Class & ID Selectors you can apply style to many selectors. #content, #footer,.supplement { position: absolute; left: 510px; width: 200px; } 22

PSEUDO SELECTOR a:link { color: #008080; } a:hover { color: #FF0000; } 23

COMMENTS IN CSS /* p { font-family: sans-serif; font-size: 15pt; } */ 24

CSS – Measurement Units CSS supports a number of measurements including absolute units such as inches, centimeters, points, and so on, as well as relative measures such as percentages and em units. You need these values while specifying various measurements in your Style rules. Example: border: 1px solid red; 25

CSS UNITS of MEASURE (1/3) # column1 { width: 100%; } p { font-size: 12pt; } p { font-size: 1pc; } 26

CSS UNITS of MEASURE (2/3) p { margin-left: 2ex; } p { padding-right:.25in; } p { padding-right: 10mm; } 27

CSS UNITS of MEASURE (3/3) p { margin-left: 2em; } div#main { width: 600px; } 28

CSS UNITS - Sizes Relative length measurements: –px (pixels – size varies depending on screen resolution) –em (usually the height of a font’s uppercase M) –ex (usually the height of a font’s lowercase x) –Percentages (of the font’s default size) Absolute-length measurements (units that do not vary in size): –in (inches) –cm (centimeters) –mm (millimeters) –pt (points; 1 pt = 1/72 in) –pc (picas; 1 pc = 12 pt) Generally 1em = 12pt = 16px = 100% 29

UnitDescriptionExample % Defines a measurement as a percentage relative to another value, typically an enclosing element. p { font-size: 16pt; line-height: 125%; } cm Defines a measurement in centimeters.div {margin-bottom: 2cm;} em A relative measurement for height of a font in em spaces. Because an em unit is equivalent to the size of a given font, if you assign a font to 12pt, each “em” unit would be 12pt; thus 2em = 24pt. p { letter spacing: 7em; } ex This value defines a measurement relative to a font’s x-height. The x-height is determined by the height of the font’s lowercase letter x. p { font-size: 24pt; line-height: 3ex; } in Defines a measurement in inches.p { word-spacing:.15in;} mm Defines a measure in millimeters.p { word-spacing: 15mm;} pc Defines a measurement in picas. A pica is equivalent to 12 points. Thus, there are 6 picas per inch. p { font-size: 20pc;} 30

31 UnitDescriptionExample pt Defines a measurement in points. A point is defined as 1/72 nd of an inch. body {font-size: 18pt;} px Defines a measurement in screen pixels.p {padding: 25px;}

CSS – Colors You can specify your color values in various formats. 32 FormatSyntaxExample Hex Code#RRGGBBp {color: #FF0000; } Short Hex Code#RGBp {color: #6A7;} RGB %rgb(rrr%, ggg%, bbb%) p { color: rgb(50%, 50%, 50%); } RGB Absolutergb(rrr, ggg, bbb) p { color: rgb(0, 0, 255); } keywordaqua, black etc.p { color: teal;}

CSS Box Model A set of rules collectively known as CSS Box Model describes the rectangular region occupied with HTML elements. The main idea is that every element’s layout is composed of:  the actual element’s content area.  a border around the element.  a padding between the content and the border (inside the border)  a margin between the border and other content (outside the border) 33

34

Document Flow - Block Elements 35

Document Flow – Inline Elements 36

Document Flow – Larger Example 37