CSS Classes.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

Table, List, Blocks, Inline Style
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Introduction to CSS.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
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.
CSS Classes.
XP Mohammad Moizuddin Creating Web Pages with HTML Tutorial 1 1 New Perspectives on Creating Web Pages With HTML Tutorial 1: Developing a Basic Web Page.
CSS Basic (cascading style sheets)
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP 2 HTML Tutorial 1: Developing a Basic Web Page.
Cascading Style Sheets Creating a Uniform Site. Style Sheets  Style sheets are used for conformity on a web page or web site.  Style sheets eliminate.
Cascading Style Sheets CSS. Source W3Schools
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS Syntax. Syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property: value}
XP 2 HTML Tutorial 1: Developing a Basic Web Page.
XP 1 HTML Tutorial 1: Developing a Basic Web Page.
HTML5 and CSS3 Illustrated Unit C: Getting Started with CSS.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 1 Using HTML to Create Web Pages.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
CSS Classes and IDs.
Fall 2016 CSULA Saloni Chacha
Cascading Style Sheets (CSS)
Cascading Style Sheet.
Tutorial 1 – Creating Web Pages With HTML
Web Basics: HTML/CSS/JavaScript What are they?
Getting Started with CSS
CSS Classes.
4.01 Cascading Style Sheets
>> Introduction to CSS
Introduction to CSS.
Introduction to the Internet
Madam Hazwani binti Rahmat
HTML Formatting.
Cascading Style Sheets (CSS)
Programming the Web using XHTML and JavaScript
Introduction to Web programming
AN INTRODUCTORY LESSON TO MAKING A SIMPLE WEB PAGE By: RC Emily Solis
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheet (CSS)
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Cascading Style Sheets - Building a stylesheet
Working with HTML These are the examples you need to go over. Click on the name like HTML5intro.html and it will bring up the page. If you right click.
Introduction to CSS.
Intro to CSS CS 1150 Spring 2017.
CSS Classes and IDs.
DynamicHTML Cascading Style Sheet Internet Technology.
Cascading Style Sheets
محمد احمدی نیا CSS محمد احمدی نیا
Web Programming– UFCFB Lecture 11
Working with Cascading Style Sheets (CSS)
Working with Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
DynamicHTML Cascading Style Sheet Internet Technology.
CSS Classes and IDs.
Tutorial 3 Working with Cascading Style Sheets
Introduction to CSS.
Chapter 6 Introducing Cascading Style Sheets
Cascading Style Sheet.
Session 3: Basic CSS Spring 2009
Cascading Style Sheets - Building a stylesheet
4.01 Cascading Style Sheets
External Style Sheets.
Cascading Style Sheets III B. Com (Paper - VI) & III B
CSS Classes and IDs.
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

CSS Classes

What is a CSS Class? A CSS class provides us with a tool to create custom styles for elements on our web pages. Using classes can save us from typing the same formatting code for numerous elements. Classes enable us to make wide-scale styling changes very quickly. In our earlier examples of using CSS, we applied the same formatting to all instances of a particular element. A CSS class allows us to define different styles for the same element type. For example, we can make one paragraph appear in green text and another paragraph show in red text.

Syntax and Use of CSS Classes: <head> <style type="text/css"> .center { text-align:center; } </style> </head> Class definitions are placed along with all the other CSS inside the <head> section of the document. A CSS class is defined with a period, followed by the name of the class. <p>Paragraph 1</p> <p class="center">Paragraph 2</p> By adding the class="center" to this paragraph element, we are telling the browser to apply all formatting defined for that class to this particular paragraph. Paragraph 1 Paragraph 2

Syntax and Use of CSS Classes: <head> <style type="text/css"> .special { text-align:center; color:green; font-style:italic; } </style> </head> As before, multiple styles can be defined in a single statement. Remember the semicolon at the end of each line. <p class="special">Paragraph</p> Paragraph

Syntax and Use of CSS Classes: <head> <style type="text/css"> .center { text-align:center; } .green { color:green; .italic { font-style:italic; </style> </head> CSS classes can even be combined. The element will reflect the formatting definitions from all the classes being applied. <p class="center green italic">Paragraph</p> Paragraph

Syntax and Use of CSS Classes: <head> <style type="text/css"> .green { color:green; } </style> </head> <h1 class="green">Heading</h1> <p class="green">Paragraph</p> <ul> <li>List Item 1</li> <li class="green">List Item 2</li> </ul> Generic classes like these can be applied to any element we choose. Heading Paragraph List Item 1 List Item 2

Syntax and Use of CSS Classes: <head> <style type="text/css"> p.green { color:green; } </style> </head> You can also specify that only particular elements be affected by a class. In this example, we have defined the .green class to apply only to the paragraph element. <h1 class="green">Heading</h1> <p class="green">Paragraph</p> <ul> <li>List Item 1</li> <li class="green">List Item 2</li> </ul> If we try to apply the .green class to other elements, it will have no effect; the browser will simply ignore the class definition. Heading Paragraph List Item 1 List Item 2

The <span> element: <head> <style type="text/css"> .green { color:green; } </style> </head> The <span> tag allows us to apply class styling to a specific section within an element. Note that the <span> tag does nothing on its own. Only when we associate it with a class does it make a change to how the page displays. <p>This is a <span class="green"> typical</span> paragraph</p> This is a typical paragraph.

Naming CSS Classes: Give some thought to how you name your CSS classes. By using class names that describe how the element will look (.green, .center), we can make things confusing in the future. What if we later change our green text to be red? We would have the .green class display in red! A much better approach is to use class names that describe the meaning of the content, not how it will look: Problematic names .green .underline .center .bigletters Better names .slogan .booktitle .caption .headline