Understanding ID and Class in CSS Web Design – Sec 4-9 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.

Slides:



Advertisements
Similar presentations
HIGH LEVEL OVERVIEW: CSS CSS SYNTAX CONSISTS OF A SET OF RULES THAT HAVE 3 PARTS: A SELECTOR, A PROPERTY, AND A VALUE. IT’S NOT NECESSARY TO REMEMBER THIS.
Advertisements

HTML: HyperText Markup Language Hello World Welcome to the world!
Cascading Style Sheets
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Cascading Style Sheets
CHAPTER 7 STYLING CONTENT WITH CASCADING STYLE SHEETS.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
WEB DESIGN – SEC 4-11 PART OR ALL OF THIS LESSON WAS ADAPTED FROM THE UNIVERSITY OF WASHINGTON’S “ WEB DESIGN & DEVELOPMENT I ” COURSE MATERIALS PSEUDO-CLASS.
กระบวนวิชา 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.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Lecture Cascading Style Sheets (CSS) Internal Style Sheets Classes.
SM5312 week 6: basic CSS syntax1 An Introduction to Cascading Style Sheets Basic CSS Syntax Nick Foxall.
4.01 Cascading Style Sheets
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.
Cascading style sheets (CSS)
Robby Seitz 121 Powers Hall ADVANCED WEB DESIGN USING DREAMWEAVER.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Today’s objectives  Complete web page  Using xhtml & CSS  Adding CSS to documents Embed url(File);  CSS.
Unit 3, Lesson 3 Typography. art and technique of arranging type on a page. font family, style, size, and weight (or thickness)
Styles with Cascading Style Sheets (CSS) Web Design – Section 4-1 Part or all of this lesson was adapted from the University of Washington’s “Web Design.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
Styling and theming Build campaigns in style. What we'll look at... How a web document is structured How HTML and CSS fit together Tools you will need.
IDs versus Classes Naming Your Tags for Maximum Functionality.
More Basic HTML. Add spacing (single & double space) Save Refresh Add horizontal rule Add comments Add styles Add headings Add features Add alignments.
1 WDMD 170 – UW Stevens Point WDMD 170 Internet Languages eLesson: CSS Introduction to Style Sheets (NON-audio version) © Dr. David C. Gibbs
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 14, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
WEB DESIGN UNIT 2 Unit 2 Module 2-5. WHAT HAVE YOU LEARNED?  What is the title tag do? Where does it show?  What are the tags that need to be on every.
Working with Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 5.
Cascading Style Sheets Dave Edsall IAGenWeb County Coordinator’s Conference June 30, 2007.
CO1552 – Web Application Development Cascading Style Sheets.
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.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Linking to an External Style Sheet Web Design Section 4-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
HTML.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
1 © Netskills Quality Internet Training, University of Newcastle Using Style Sheets in Dreamweaver CS © Netskills, Quality Internet Training, University.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
External Style Sheets Exploring Computer Science – Lesson 3-6.
Cascading Style Sheets (CSS) EXPLORING COMPUTER SCIENCE – LESSON 3-5.
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.
Group 9: Through examples, explain how to build a css navigation bar. Presented by: Daniel Ku, Matt Iannacci & Iphia Henry.
Creating Layouts with CSS. Span tag Here is some underlined text. Here is some blinking text. Here's some bold text.
Stylizing a Navigational Menu Web Design Section 6-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
HTML5 and CSS3 Illustrated Unit C: Getting Started with CSS.
EXTERNAL STYLESHEETS AND MORE HTML STYLING HTML and CSS part 2.
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
CSS (Cascading Style Sheets). CSS CSS – Cascading Style Sheets – Cascade because of the way CSS rules can stack on top of each other. Allows you to add.
Introduction to CSS: Selectors
Cascading Style Sheets (CSS) Internal Style Sheets Classes
Cascading Style Sheets (CSS)
The Box Model in CSS Web Design – Sec 4-8
4.01 Cascading Style Sheets
The Box Model in CSS Web Design – Sec 4-8
>> Introduction to CSS
Cascading Style Sheets (Layout)
The Box Model in CSS Web Design – Sec 4-8
Intro to CSS Mr. Singh.
Working with Cascading Style Sheets (CSS)
Working with Cascading Style Sheets (CSS)
Training & Development
4.01 Cascading Style Sheets
Web Programming and Design
Modifying HTML attributes and CSS values
Presentation transcript:

Understanding ID and Class in CSS Web Design – Sec 4-9 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials

 The student will  Be able to identify how ID attributes are used in CSS to enable styling of individual elements.  Be able to identify how Class attributes are used in CSS to enable styling of groups of elements.  Have added ID and Class attributes to certain elements within a web page. Objectives

 You have added style to various elements in your portfolio page, but the styles you've added have affected all elements of a particular type.  For example, when you added style to the div element that affected all div elements equally.  What if you want to stylize some div elements one way, and other div elements a different way? That's where id and class come in. In this lesson you will learn how ID and Class attributes can be used to stylize individual elements (id) or groups of elements (class). IDs and Classes

 Every element on your web page can be assigned a unique id attribute.  This can be any text you like, but it has to be unique (only one item can have this label).  It's a good practice to assign labels that describe the function of the element.  For example, a that's used to markup a navigation menu might have id="navigation" or id="menu" What is an ID?

 You assign an id attribute to an HTML element when: 1.You want to stylize that element differently than other elements of the same type. 2.You want to be able to link to a particular element within a web page. In fact, you already added id="main" to one of the div elements on your portfolio page when you created a "skip to main content" link. 3.You want to be able to directly access that element using Javascript. You'll learn more about that in the lesson on Javascripts.  Today we’re just looking at reason 1 When to use an ID

ID Example  Let's say you have a paragraph that serves as an alert on a page. You don't want it to look like all the other paragraphs on the page. You want it to stand out so people are sure to notice it. You could add id="alert" to that paragraph, like this: Important! All classes are cancelled today.  To add style to an element with an id, you preface the id with a # symbol in your CSS: #alert { color: black; font-weight: bold; background: #FFFF66; /* yellow */ }

 A class allows you to stylize a group of elements the same way.  Unlike ID, you can use the same class name for multiple items. What is a Class?

 You're creating an entertainment web page that includes several movie reviews, in addition to other content. The entire content of each review (a heading with the movie title, plus several paragraphs) is wrapped in a in order to keep it all together in one box. The first paragraph of each review is a short summary describing the movie, then all remaining paragraphs contain the content of your critique of the movie. You may want to stylize the elements that contain each review differently than other elements on the page, so reviews all have a distinct look, but consistent with one another. You could accomplish this by assigning class="review" to each of these reviews. Also, you might want the summary paragraph to have a distinctive look, different from all other paragraphs. You could accomplish this by assigning class="summary" to each summary paragraph. Class Example

 The HTML would look like this: The Godfather The Godfather (1972) is the greatest movie of all time, according to numerous surveys of movie critics and audiences alike. The Godfather is... (your review here) Avatar Avatar (2009) is the highest grossing film of all time, earning approximately $2.8 billion. Avatar is... (your review here)  The CSS code might look like this: div.review { background-color: #E6EBF5; border: 1px solid #003399; } p.summary { font-style: italic; }

Class Example - Result

 In addition to assigning styles to a class of elements, you can also assign styles to descendants of those elements.  A descendant is an element that is nested inside another element. Descendant Selectors

 Let's say you wanted all elements (links) on a page to be red and underlined. Here's how you could accomplish that in CSS: a { color: red; text-decoration: underline; }  However, let's also say you wanted a different style for links that are part of your navigation menu. You want them to be white text on a dark blue background, with no underline. Assuming these links are contained within a with id="navigation", you could stylize those using descendant selectors in CSS, like so: ul#navigation a { color: white; background-color: #003399; /* dark blue */ text-decoration: none; }  the selector ul#navigation a tells the browser to apply the style definition to every element that's inside of the element that has id="navigation". Descendant Example

 Download the instructions for today.  When you are done, in your index.html, every tag will have either an id or class attribute and the tags for the reflections you haven’t written will also have a class attribute.  You also need to update two tags in all your other html files. Rest of Today