>> 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.

Slides:



Advertisements
Similar presentations
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Advertisements

Cascading Style Sheets
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
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.
Some SpotLight in CSS. CSS element>element Selector div>p.
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 Link Styling. The Anchor Element: Link text between the opening and closing can be styled using CSS. Some of the properties that can be set are: font-family,
Today’s objectives  Element relations – tree structure  Pseudo classes  Pseudo elements.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
Cascading Style Sheets Based on Castro, HTML for the WWW, 6 th edition Ron Gerton, Fall 2007.
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.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
กระบวนวิชา 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.
WEB DESIGN Multimedia and Web. Today’s Objectives  Quick review selector types  Layout and positioning.
AD Intermediate Computer Graphics | spring 2008 | Daria Tsoupikova | School of Art and Design | UIC CSS Cascading Style Sheets.
Design, Formatting, CSS, & Colors 27 February, 2011.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
Controlling Page Style: Cascading Style Sheets (CSS) References: 1.Wang, P.S & Katila, S. (2004). A Introduction to Web Design and Programming. CA: Thomson.
4.01 Cascading Style Sheets
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
CSS Dvijesh Bhatt.
Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
MORE Cascading Style Sheets (The Positioning Model)
Tutorial 4 Creating Special Effects with CSS
WDV 101 Intro to Website Development
Doman’s Sections Information in this presentation includes text and images from
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Part 1: CSS - Why? - How it works - Writing rules - Examples.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
Tutorial #4 Formatting Text and Links. Tutorial #3 Review - CSS CSS format Selector { property1: value1; /* Comments */ } Embedded, In-Line, and External.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
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.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
CSS – 1h. Without stylesheets proprietary HTML extensions making text into images proliferate use of "spacer" GIF images deprecated HTML elements and/or.
CSS: Cascading Style Sheets Part II. Style Syntax.
Advanced CSS. Display  Hiding an element can be done in two ways  display:none  Element is hidden and will no longer take up space on the page  Can.
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.
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.
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
1 Cascading Style Sheets
Cascading Style Sheets
4.01 Cascading Style Sheets
Cascading Style Sheets
>> Introduction to CSS
>> The “Box” Model
>> More on CSS Selectors
>> CSS Rules Selection
Cascading Style Sheets
Cascading Style Sheets (Layout)
CSS Intro.
The Web Wizard’s Guide To DHTML and CSS
>> Dynamic CSS Selectors
Cascading Style Sheets
4.01 Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Presentation transcript:

>> 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 the text in HTML section

Recall Types of Selectors – Element/Type Selector – ID Selector (#) – Class Selector (.) Combining Selectors – Use a “,”

Sample File DOM Tree Web-based Systems | Misbhauddin 4 HTML BODY

Universal Selector Universal selector is used when you want to apply the style to all elements within the page. – It does not have any weight USAGE: * Web-based Systems | Misbhauddin 5 Select and color all elements Try Now

Within Selector This is used to select selectors that are either within or beside each other – No space between the name USAGE EXAMPLE: div.test Web-based Systems | Misbhauddin 6 Select the label element with class required and color it red. Try Now

Descendant Selector Descendant means anywhere nested within it in the DOM tree – Could be a direct child, could be five levels deep, it is still a descendant USAGE: white space between two selectors Web-based Systems | Misbhauddin 7 Select and color all paragraph descendants of the div tag with id “first-div” Try Now

Child Selector It means "select elements that are direct descendants only“ USAGE: > between two selectors – Example: div > p Web-based Systems | Misbhauddin 8 Select and color all paragraph children of the div tag with id “first-div” Try Now

General Sibling Selector This selects elements at the same hierarchy level USAGE: ~ between two selectors – Example: div ~ p Web-based Systems | Misbhauddin 9 Select and color all paragraph siblings of the div tag with id “nested-div” Try Now

Adjacent Sibling Selector This means is "select a tag that is directly after another given tag (with nothing in between)“ USAGE: + between two selectors – Example: div + p Web-based Systems | Misbhauddin 10 Select and color the paragraph sibling of the div tag with id “first-div” Try Now

Attribute Selector This means is “select a tag when the attribute value is equal to the specified value“ – Weight is equal to a class selector USAGE: tag[attribute=“value”] – Example: input[type=“text”] Web-based Systems | Misbhauddin 11 For the input with type password, set the color to green Try Now [prop = value] Exactly equal to the value [prop *= value] Contains value somewhere [prop ^= value] Begins with value [prop $= value] Ends with value

DYNAMIC STYLING IN CSS Advanced CSS Selectors Web-based Systems | Misbhauddin 12

Can be done by CSS for specific cases Also called Pseudo selectors Web-Based Systems - Misbhauddin 13 Styling Dynamically Types of Pseudo Selectors Pseudo-Class Selectors Pseudo-Element Selectors Apply styles to part of other actual elements that cannot be shown in the DOM tree Select elements that can't be expressed using attributes, IDs or classes 1.LINK 2.FORM

Link States Web-Based Systems - Misbhauddin 14 LINK Page loads HOVER Mouse Over Move out ACTIVE Click [Button Pressed] VISITED Clicked [Button Released] Mouse Over Mouse Out Link Pseudo Class Selector

Use “:” after the selector – LINK State a:link {} – VISITED State a:visited {} – HOVER State a:hover {} – ACTIVE State a:active {} Web-Based Systems - Misbhauddin 15 Specifying them in order is ideal Easy way to cover them all: LOVE/HATE Link Pseudo Class Selector L :link O V :visited E H :hover A :active T E Weight is equal to a class selector

TRY NOW Web-Based Systems - Misbhauddin 16 Style the hyperlink with the following specifications Link: red Visited: green Hover: blue Active: yellow Use attribute color HINTS:

Use “:” after the input selector – :hover – :focus – :required – :valid – :invalid Web-Based Systems - Misbhauddin 17 Form Pseudo Class Selectors

TRY NOW Web-Based Systems - Misbhauddin 18 For the input type Invalid: background color to red Valid: background color to green Hover: background color to yellow Focus: outline 1px solid black Use attribute background outline: 5px solid black border-color HINTS: For the password input type required: border color to red

Use “::” after the selector – ::first-line – ::first-letter Web-Based Systems - Misbhauddin 19 Some Pseudo Element Selectors

TRY NOW Web-Based Systems - Misbhauddin 20 Use attribute font-size HINTS: For the all paragraphs first-letter: font size to 30px

Next on Web-based Systems Cascading Style Sheets – The “Box Model” in CSS – Using to format the layout of an HTML page Using, tags and CSS code Details on Selectors and Properties –