CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.

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

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 Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
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.
Working with Cascading Style Sheets
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.
Streamlining Website Development in Dreamweaver Roger L. Runquist Western Illinois University Roger L. Runquist Western Illinois University.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
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.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSSMR.Mostafa badr1. Lesson 3 Creating an Style Sheet Lesson 2 Structure of the Style Lesson 1: What Cascading Style Sheets are?
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.
 Missing (or duplicate) semicolons can make the browser completely ignore the style rule.  You may add extra spaces between the properties/values to.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Cascading style sheets (CSS)
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Doman’s Sections Information in this presentation includes text and images from
MCS 270 Cascading Style Sheets (CSS) Gustavus Adolphus College.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
WRT235: Writing in Electronic Environments CSS Classes, IDs, divs.
FTS: The Perils and Promise of Computing Cascading Style Sheets (CSS) Gustavus Adolphus College Fall 2012.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 7.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
 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 (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Extra-simplified.  Only truly happen when the CSS and HTML are defined as separate files (external style sheet) Introduction The main idea of CSS is.
Relative, absolute, and Floating Positioning, Cascading Style Sheet, and Inheritance.
CSS: Cascading Style Sheets Part II. Style Syntax.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
CSS FOUNDATIONS IN-DEPTH The nitty-gritty of css...
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
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.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
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.
Working with Cascading Style Sheets
4.01 Cascading Style Sheets
CSS: Cascading Style Sheets
IS 360 Declaring CSS Styles
Madam Hazwani binti Rahmat
Cascading Style Sheets
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Styles and the Box Model
DynamicHTML Cascading Style Sheet Internet Technology.
DynamicHTML Cascading Style Sheet Internet Technology.
4.01 Cascading Style Sheets
Presentation transcript:

CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document and its presentation - semantics  content - presentation  style how it appear on the web page

Advantages of Style Sheets Saves time Easy to change Keep consistency Give you more control over layout Use styles with JavaScript => DHTML Make it easy to create a common format for all the Web pages

Media attribute in link tag

Applying a single style sheet to multiple documents

Basic Structure of a Style Each definition contains: –A property –A colon –A value –A semicolon to separate two or more values –Can include one or more values h1 {font-size:12pt; color:red} h1 is the selector

Style Precedence 1.External style sheet 2.Embedded styles 3.Inline styles

Three Style Types Inline styles –Add styles to each tag within the HTML file –Use it when you need to format just a single section in a web page Example – IU

Three Style Types Embedded or internal styles –A style is applied to the entire HTML file –Use it when you need to modify all instances of particular element (e.g., h1) in a web page Example – h1 {color:red; font-family:sans-serif} –

Creating an Embedded Style Embedded Example (default is “text/css”) Style declarations A style declaration: –Selector {attribute1:value1; attribute2:value2; …} –Selector = an element in a document (e.g., a header or paragraph)

An Example of an embedded style Getting Started h1 {font-family: sans-serif; color: organge}

Three Style Types External style sheets –An external style sheet is a text file containing the style definition (declaration) –Use it when you need to control the style for an entire web site Example –h1, h2, h3, h4, h5, h6 {color:red; font- family:sans-serif} –Save this in a new document using a.css extension

Creating an External Style Sheet Open a new blank document in Notepad Type style declarations –h1 {color:red; font-family:sans-serif;} Do not include tags Save the document as filename.css

Linking to Style Sheets 1 Open an HTML file Between and add – URL is the file.css Relation_type=“stylesheet” Link_type=“text/css” Save this file and the.css file in the same web server directory

An example of an external style sheet with an original html file Getting Started h1 {font-family: sans- serif; color: orange} b {color: blue} html file Text file of css named “stylesheet”

Style Sheet Strategies Wherever possible, place your styles in external style sheets Take advantage of the power of CSS to have control over an entire Web site

Selector Strings Type selector - simply the name of the element type - separated by commas - eg. h1,h2,h3 {color:red; font-family:sans-serif;} Universal selector - denoted by asterisk * - * { font-weight:bold } for every element in the document ID selector

Using IDs and Classes Use an id to distinguish something, like a paragraph, from the others in a document. –For example, to identify a paragraph as “head”, use the code : …

Working With Ids To create an ID for a specific tag, use the property: – To apply a style to a specific ID, use: –#id_name {style attributes and values}

Classes HTML and XHTML require each id be unique– therefore an id value can only be used once in a document. You can mark a group of elements with a common identifier using the class attribute. …

Applying a style to a class

Working With Classes To create a class, enter the following in the HTML tag: – – IU –class_name is a name to identify this class of tags To apply a style to a class of tags, use: –tag.class_name {style attributes} or –.class_name {style attributes}

Working With Classes and Ids The difference between the Class property and the ID property is that the value of the ID property must be unique: –you can’t have more than one tag with the same ID value –You can apply the same Class value to multiple document tags

Pseudo Classes Pseudo classes are used to add special effects to some selectors Syntax selector:pseudo-class {property:value;} Example a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */ Eg Pseudoclass.html

At-rules This rule is used to input one style sheet into another one. url{ “gen-rules.css”} h1, h2 {background-color:aqua}

Rule cascading Rule cascading  a multistage sorting process that selects a single declaration that will supply the property value. Steps: 1.Which external or embedded style sheets apply to the document ( external includes alternate as well as media type) 2.Origin and weight with every declaration of property of element

Rule cascading Origin  who wrote the declaration * Author :person who wrote the HTML doc (or) * User Agent: A browser / other user agent who define style property values * User: User can indicate style preferences Weight  normal or !important

Rule Cascading Priority 1.Important with user origin 2.Important with author origin 3.Normal with author 4.Normal with user 5.Any declaration with user agent

Rule cascading Specificity Priority 1.ID selectors 2.Class and pseudo-class selectors 3.Type selectors 4.Universal selectors Eg rule cascdng.html

Style Inheritance Inheritance properties are passed from parent to child elements properties have not been explicitly defined by other means. Certain properties are inherited automatically, a child element will take on the characteristics of its parent with regards to these properties.

Working With DIV tag is used for blocks of text, e.g., paragraphs, block quotes, headers, or lists To create a container for block-level elements, use: – Block-level elements – –Class_name is the name of the class –You can substitute the ID proper for the Class property (with ID, the syntax for CSS style, #id_name {style attributes and values}

Working With DIV.Slogan {font-weigh:bold} Maxwell Scientific’s new Slogan is: ”We teach science” style HTML code Maxwell…: “We teach… Resulting text

Working With With the tag, you can use inline elements, e.g.,, To create a container for inline elements, use: – inline elements –

CSS for Page Layout CSS manipulates the size and location of block- level elements Block-level elements in HTML: –Heading tags, e.g.,, – – and tags –List tags, e.g.,,, –

CSS Box Model Parts of the block-level elements: –Margin –Border –Padding

CSS Box Layout I appreciate the prompt delivery of the pack of star disks. border margin padding

Controlling the Margins To define the margins of an element, use: –margin:value –where value = a length value (“em” is often used), a percentage (a margin proportional to the element’s width, or auto

Controlling the Margins To set margins on a side, use: –margin-top –margin-right –margin-bottom –margin-left E.g., LI {margin-top: 15px; margin-right: 45px; margin-left: 45px ; margin-bottom: 30px;} (or) Margin: 15px 45px 30px

Number of values one  assign to all ( top, right, bottom & left) Two  first value assign to top & bottom, second value to right & left Three  first to top, second to right & left, third to bottom.

Setting the Padding Size To define padding, use: –padding: value –where value = a length value or a percentage (a padding proportional to the element’s width)

Setting the Padding Size To set margins on a side, use: –padding-top –padding-right –padding-bottom –padding-left

Formatting the Border Border can be set in three ways: –border-width –border-style –border-color

Formatting the Border To set the border, use: –border:width_value style color To set borders on a side, use: –border-top –border-bottom –border-left –border-right

Formatting Width & Height of Block-Level Boxes To set the width of a block-level element, use: –width:value –height:value –where value can be a length value, a percentage, or auto E.g., textarea {width:225px; height:100px}

Simple Inline Boxes Eg BIG

Beyond the Normal Flow Three alternatives 1. relative positioning  position is altered relative to its normal flow position 2. float positioning  inline element moves to one side or the other of its line box 3. absolute positioning  element is moved entirely from the normal and placed somewhere else.

Properties for positioning position: static  indicates the normal flow position : relative / absolute / fixed Fixed positioned elements can overlap other elements. float ( static or relative pos): none/right / left an element can be pushed to the left or right, allowing other elements to wrap around it.

Using the Float Attribute float:right width:50px float:right width:50px clear:right