CSS Basics Style and format your web site using CSS.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Advertisements

Cascading Style Sheets
1 © Netskills Quality Internet Training, University of Newcastle Introducing Cascading Style Sheets © Netskills, Quality Internet.
HTML Basics Customizing your site using the basics of HTML.
Basic Principles for Web Design Source:
HTML and CSS. HTML Hyper Text Markup Language Tells browser how to display text and images.
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.
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Intro To Cascading Style Sheets By Mario Yannakakis.
Internet Services and Web Authoring (CSET 226) Lecture # 5 HyperText Markup Language (HTML) 1.
CSS Cascading Style Sheets. What is CSS? CSS stands for Cascading Style Sheets (the page—or sheet—helps you create a style that will cascade across all.
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style.
Ideas to Layout Beginning web layout using Cascading Style Sheets (CSS). Basic ideas, practices, tools and resources for designing a tableless web site.
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
Today CSS HTML A project.
CHAPTER 7 STYLING CONTENT WITH CASCADING STYLE SHEETS.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
INTRODUCTION TO HYPERTEXT MARKUP LANGUAGE 1. Outline  Introduction  Markup Languages  Editing HTML  Common Tags  Headers  Text Styling  Linking.
CSS. Intro to CSS Cascading Style Sheets – styles and enhances appearance of webpage.css extension.
Introduction to CSS. What is CSS? A CSS (cascading style sheet) file allows you to separate your web sites (X)HTML content from it’s style. Use your (X)HTML.
CSS. CSS, or Cascading Styles Sheets, is a way to style HTML. Whereas the HTML is the content, the style sheet is the presentation of that document.
Introduction to CSS.
Cascading Style Sheets (CSS): Pixel-Level Control with HTML Ease
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.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
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.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
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 Dreamweaver CS5 intermediate class by Cookie Setton Build a CSS website WITHOUT TABLES Just when you thought you were starting to understand HTML coding,
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
“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.
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.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
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.
 Missing (or duplicate) semicolons can make the browser completely ignore the style rule.  You may add extra spaces between the properties/values to.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
3. Cascading Style Sheets (CSS) M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
Coding with HTML {. THE BASICS { What is HTML and how can you use it to make websites?
CSS Cascading Style Sheets *referenced from
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.
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.
4.01 Cascading Style Sheets
>> Introduction to CSS
Madam Hazwani binti Rahmat
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Introduction to CSS.
The Internet 10/13/11 The Box Model
Training & Development
Tutorial 3 Working with Cascading Style Sheets
Understand basic HTML and CSS terminology, concepts, and basic operations. Objective 3.01.
Stylin’ with CSS.
4.01 Cascading Style Sheets
Stylin’ with CSS.
Presentation transcript:

CSS Basics Style and format your web site using CSS

What is CSS?  CSS (Cascading Style Sheets) allows us to apply formatting and styling to the HTML that builds our web pages.  CSS can control many elements of our web pages: colors, fonts, alignment, borders, backgrounds, spacing, margins, and much more.

How does CSS work?  CSS works in conjunction with HTML.  An HTML file (or multiple files) links to a CSS file (or multiple CSS files) and when the web browser displays the page, it references the CSS file(s) to determine how to display the content.  HTML elements are marked with “IDs” and “classes,” which are defined in the CSS file – this is how the browser knows which styles belong where. Each element type (,,,, etc.) can also be styled with CSS.  IDs and classes are defined by the person writing the code – there are no default IDs and classes.

What is the difference between ID and class?  IDs and classes function the same way – they can both provide the same styling functionality to an HTML element, however…  IDs are unique; each element can only have one ID, and that ID can only be on the page once.  Classes are not unique; an element can have multiple classes, and multiple elements can have the same class.  What does that mean?  IDs can be used to style elements that are different from anything else on the page.  Classes can be used to style multiple elements on a single page that have things in common, like font size, color, or style.

What does a CSS file look like?  The styles for each element, ID, or class used on an HTML page are defined in a CSS document. #title {}  Classes are declared with a period and the class name; styles for the class are wrapped with curly brackets:.bodytext {}  IDs are declared with a pound sign and the ID name; styles for the ID are wrapped with curly brackets:  Elements are declared with the element (HTML) tag; styles for the element are wrapped with curly brackets: h1 {}

What does a CSS file look like?  Within each CSS element, styles are added that apply to that particular element/ID/class: h1 { color: green; }  This style would apply to anything within HTML tags; the text inside the tags would be green.

Adding CSS to HTML  CSS must be used in conjunction with HTML to be effective. CSS files can be linked to HTML documents with a bit of code in the tags of an HTML file:  CSS can also be written “in line,” within HTML code, but it’s preferable to include an external style sheet: Lorem ipsum…

Let’s write some CSS!  We’ll work in a web-based editing tool, but CSS can easily be written in text editing software like Notepad.  Go to  *This tool references our CSS automatically, so in this case, we don’t need to link our CSS file like we normally would.

Adding IDs and Classes to HTML  First, we need to add our IDs and classes to the HTML: Wolverine This class won’t do anything yet. We’ll define its associated styles in our CSS file.

Adding IDs and Classes to HTML The wolverine, also referred to as glutton, carcajou, skunk bear, or quickhatch… The adult wolverine is about the size of a medium dog, with a length usually ranging from… … We’re adding a class and an ID to this paragraph; we want the styles from both to be applied to it. We only want the styles from one class to apply to this paragraph.

Defining Elements in CSS  We’ve added IDs and classes to our HTML file, but we need to define what those IDs and classes will do.  How will each class or ID change the appearance of that HTML element?  This is where CSS comes in!  By defining the styles that go with each attribute/class/ID, we have complete control over the look of our content.

Writing CSS  Let’s create a new CSS document in Notepad.  We’ll begin by defining the “bordered” class that is applied to one of the images.  CSS uses. to identify classes, and # to identify IDs. Because our HTML indicates class=“bordered” we need to use the matching identifier in our CSS document..bordered { } All the styles inside these brackets will be applied to any elements in our HTML file that include class=“bordered”.

Writing CSS  First, let’s add a simple style to.bordered:.bordered { width: 300px; } Each style ends with a semicolon.  Now, any HTML element that includes class=“border” will be 300 pixels wide.

Writing CSS  Let’s add a border to that image that has class=“bordered”.  The “border” style requires some additional attributes..bordered { width: 300px; border: 3px solid #000000; } Tells the browser “I want a border around this element.” The border should be 3 pixels wide. The border should be solid. (Other possible values include dotted and dashed.) The border should be black (defined by hexadecimal color code).

Using Colors in CSS  Though there are standard color names that are supported by all browsers (i.e. green, red, yellow, etc.), colors are often declared in CSS using hexadecimal color codes.  How can I find the hex color code? Color picker tool in Photoshop/image editing software. Online tools: Official UVU web colors:

Writing CSS  We want the image to be on the right side of the page, so we need to add a “float” to the class styles:.bordered { width: 300px; border: 1px solid #000; float: right; } We could also align the element to the left side of the page using “float: left;”.

Writing CSS  Next, let’s write some styles to apply to our paragraphs. First, we’ll create styles for the ID called “introduction.”  We want this paragraph to stand out from the rest, so we’ll make the font size bigger and change the color. #introduction { font-size: 20px; color: #4d7123; }

Writing CSS  We want a few paragraphs to have some additional emphasis, so let’s write an additional class for those styles:.emphasis { font-style: italic; font-weight: bold; } Other font-style options include “underline,” and “normal.” Other font-weight options include “normal,” “lighter,” or numerical values.

Writing CSS  We can also apply CSS styles to HTML elements without using classes and IDs. These will apply to any HTML element of that type, unless they are overwritten by classes or IDs. h1 { font-family: “Arial”, sans-serif; } Any tag on the page will be in Arial unless the has a class that overwrites it.

Using Fonts in CSS  Because every computer has a different set of fonts installed by default, we can’t know for sure if our visitors will have a certain font on their computer.  If we design our site using a certain font, and a visitor doesn’t have that font installed, our site will not look as we intended it to.  Luckily, there is a set of “web safe” fonts that most computers have. Choosing from these fonts will make our site look (almost) the same on any computer.  Web safe fonts include: Times New Roman, Georgia, Arial, Tahoma, Verdana. More info:  In CSS, the font-family style often includes a list of a few fonts, so that there is a “fallback” option in case the font we specify first isn’t available.

Writing CSS  We may want the same styles to apply to more than one element in our site. Combining our styles can help us do this so that we don’t have to duplicate our CSS code: h1, h2 { font-family: “Arial”, sans-serif; } Adding additional, comma- separated elements, classes, or IDs allows the same styles to be used in more than one place.

More about CSS  The possibilities with CSS are endless…this is just scratching the surface  CSS can: add rollover effects to text and images, change background colors and images, create very intricate page layouts and designs, change element opacity, create gradient colors, control page layout in adaptive/responsive design (new uvu.edu mobile-friendly design), show and hide content, create animations, and much more!  A nice CSS “cheat sheet” is available at  Find more CSS tutorials at