Cascading Style Sheets

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
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.
Links.  Styling Links  Links can be styled with any CSS property (e.g. color, font-family, background-color).  Special for links are that they can.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.
กระบวนวิชา 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.
Doman’s Sections Information in this presentation includes text and images from
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
CSS Font CSS font properties define the font family, boldness, size, and the style of a text. CSS Font Families Generic family Font familyDescription Serif.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
>> More on CSS Selectors. Pre-requisite Open the file called sample.txt Copy the all the text from the file Open your browser and go to codepen.io Paste.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
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.
Developing Web Applications with HTML and CSS “Selectors and Properties”
1 CSS محمد احمدی نیا 2 Of 21 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements 
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, we’ll cover:  Brief CSS review  Creating sections with the tag  Creating inline.
Links All CSS properties can be applied on links (i.e. change colors, fonts, underline, etc). The new thing is that CSS allows you to define these properties.
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.
1 Cascading Style Sheets
WebD Introduction to CSS By Manik Rastogi.
Introduction to CSS: Selectors
Cascading Style Sheets
Cascading Style Sheet.
CSS: Cascading Style Sheets
Semester - Review.
Unit 3 - Review.
>> Introduction to CSS
Cascading Style Sheets
CSS.
Cascading Style Sheets
IS 360 Declaring CSS Styles
Madam Hazwani binti Rahmat
Web Developer & Design Foundations with XHTML
Cascading Style Sheets
Introduction to Web programming
Cascading Style Sheets
Chapter 7 Page Layout Basics Key Concepts
CSS Intro.
Cascading Style Sheets
COMP 101 Review.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets: Basics
CSS Cascading Style Sheets
Website Design 3
6 Layout.
Cascading Style Sheets 2
Lecture 4: Page Sections and the CSS Box Model
>> Dynamic CSS Selectors
Cascading Style Sheets
محمد احمدی نیا CSS محمد احمدی نیا
The Internet 10/6/11 Cascading Style Sheets
Cascading Style Sheets
Web Programming Language
Part 1: Cascading Style Sheets
CIS 133 mashup Javascript, jQuery and XML
Cascading Style Sheets
Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Cascading Style Sheets
Cascading Style Sheets
Introduction to Styling
CS332A Advanced HTML Programming
Presentation transcript:

Cascading Style Sheets Basic CSS Cascading Style Sheets

CSS – Rules Review Selector Rule Property Value CSS Rule Syntax has 3 parts: Selector Property Value Selector Rule Property Value

CSS – <link> tag review <head> <title>My title</title> <link href=“foo.css” rel=“stylesheet” type=“text/css” /> </head>

Categories of Selectors { property: value; } Syntax: Five categories of selectors HTML tag selector ID selector Class selector Pseudo-class selector (for hover, visited, etc.) Combinations of the above with modifiers

HTML Tag Selector Styles can be applied to each HTML tag For example, we have done several exercises with the <p> tag We can also apply style for other tags such as <h1>, <h3>, <ul>, <li>, <body>

ID Selector <p id=“IntroItalics”>Intro</p> The HTML id attribute Allows you to give a unique ID to any single element on the page Each ID must be unique; can only be used once in the page Does not affect the HTML output <p id=“IntroItalics”>Intro</p> <p id=“mission”>Our mission… </p>

ID Selector (continued) CSS ID selectors Applies style only to the paragraph that has the ID of mission Elements can be specified explicitly: p#mission {…} #mission {…} #mission{ font-style: italic; font-family:”Garamond”, “Century Gothic”, serif; } Exercise Practice using the ID selector on the favorites assignment

Class Selector <p class=“shout”>Hey!</p> The HTML class attribute Classes are a way to group some elements and give a style to only that group (“I don’t want ALL paragraphs to be yellow, just these three…”) Unlike an id, a class can be reused as much as you like on the page <p class=“shout”>Hey!</p> <p class=“special”>Check out our specials!</p> <p class=“special”>They are great!</p>

Class Selector CSS class selectors Applies rules to any element with class All tags with class special All p tags with class shout All h2 tags with class shout .special { font-style: italic; } p.shout{ font-size: 36px; } h2.shout{ color:#FF0000; }

Class Selector Exercise Create 2 different CSS classes for the favorites assignment and apply them to the page

Multiple Classes <h2 class=“shout”>Hey!</h2> An element can be a member of multiple classes (separated by spaces) <h2 class=“shout”>Hey!</h2> <p class=“special shout”>See our specials!</p> <p class=“shout”>We’ll beat any price!</p>

Review With your neighbor, discuss the following How many times can you use an ID selector on an HTML page? How many times can you use a Class Selector on an HTML page? How would you style multiple HTML tags, including <p> and <h1> tags with a color of #ff0000 and set the font name for a few of the <p> tags, but not all to be Comic Sans MS?

CSS pseudo-classes selector:pseudo-class{ property:value; } CSS pseudo-classes are used to add special effects to some selectors (no HTML changes needed) Syntax: a:link{ color:#FF0000; } a:hover{ color:#00FF00; selector:pseudo-class{ property:value; }

CSS pseudo-class details Can also use this format if your anchor tag has a class: a.myclass:hover { color:blue; } Always use this order when customizing links: 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 */

CSS pseudo-classes Class Description :active An active/selected element :focus An element that has keyboard focus :hover An element that has the mouse over it :link A link that has not been visited :visited A link that has been visited :first-letter The first letter of text inside an element :first-line The first line of text inside an element :first-child The first element to appear inside another

Class Selector Exercise Use CSS pseudo-classes to add style to the <a> tags in your favorites assignment

How it works HTML File CSS File #foo{ color:red; } <head> <link href=“mystyles.css”…> </head> .bar { color:blue; } <p id=“foo”>Hello</p> <p class=“bar”>World</p> h1.bar { bgcolor:yellow; } <h1 class=“bar”>My header</h1> Hello World My header

Class Assignment Use CSS rules to format a Calendar for the month of November Criteria Table is used to create calendar with 7 columns, each column represents a day (e.g Monday…). Month is displayed Days are displayed 1st November 2015 is a Sunday All 30 days are correctly displayed (no dates are missing) A days are underlined and B days are bold Holidays (November 11, 26, and 27) have a background color of grey. font-weight : bold; text-decoration: underlined;