Instructor: Mike Panitz Crash Course in CSS.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
Advertisements

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.
Computer Applications II.  A Style Sheet is a web page development tool that allows the developer to make global changes to a web page (or web site)
Cascading Style Sheets
CSS Digital Media: Communication and design 2007.
Cascading Style Sheets
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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา 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.
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
Lecture 5. CSS 2 What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles.
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
4.01 Cascading Style Sheets
Using Cascading Style Sheets (CSS) Dept. of Computer Science and Computer Information CSCI N-100.
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.
Review HTML  What is HTML?  HTML is a language for describing web pages.  HTML stands for Hyper Text Markup Language  HTML is not a programming language,
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
CSS Style Rules Guang Tong, Zhan L;lo’p[ Css Style Rule Guang Tong Zhan Three ways to insert CSS 1 External style sheet 2 Internal style sheet 3 Inline.
Cascading style sheets (CSS)
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
To Proudly supported by ferrycake.com. We will be printing Cash for your Community tokens every week in the Carmarthen Journal and Llanelli Star. The.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
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.
Web Foundations TUESDAY, OCTOBER 1, 2013 LECTURE 4: HTML COLOR CODES, INTRO TO CSS STYLES.
آموزش طراحی وب سایت جلسه چهارم– سی اس اس 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
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.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
Web Foundations WEDNESDAY, OCTOBER 2, 2013 LECTURE 5: INTRODUCTION TO CSS CONTINUED.
CSS Basic (cascading style sheets)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Essentials of HTML Class 4 Instructor: Jeanne Hart
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
DIV, Span, CSS.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
Cascading Style Sheets CSS. Source W3Schools
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
How to… Cascading Style Sheets. How to Insert a Style Sheet When a browser reads a style sheet, it will format the document according to it. There are.
Introduction To CSS by: Alexandra Vlachakis Sandy Creek High School, Fayette County Schools Content and Resources Used With Permission: Interact With Web.
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.
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…
CASCADING STYLE SHEET 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.
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.
Introduction To CSS. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Cascading Style Sheet.
4.01 Cascading Style Sheets
BIT116: Scripting Lecture 03
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
What are Cascading Stylesheets (CSS)?
4.01 Cascading Style Sheets
Web Programming and Design
Presentation transcript:

Instructor: Mike Panitz Crash Course in CSS

 I’ve got a carbon-copy binder for notes for the quarter  You’d get paid $50  Talk to me 1-on-1 for details 2

3 Document Structure Document Appearance Interactivity

What is 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 of separating content from the way it is formatted and displayed External Style Sheets can save a lot of work by adding formatting and display configuration to an entire web site External Style Sheets are stored in.css files CSS is a way to style and present the information offered in an HTML page. Whereas the HTML is the meaning or content, the style sheet is the presentation of that document, including its font size and type, item colors, item formatting, margins and padding, rows and columns, in short the look and feel of a web page or entire web site. 4

 We’re focusing on programming JavaScript  Many web pages provide interactivity by changing their appearance  Form validation: highlight the wrong elements  Changing (adding, removing) elements on the page with a specific style so that they stand out  You can create 2D games!  CSS can be used to position things  CSS +JavaScript can move things around  CSS “selector syntax” is re-used by jQuery to identify items on a page 5

6 H1 H3 P P P

 CSS is a separate language.  Since it has a different purpose (appearance) than HTML (structure), it has a different form  Goal: Get a feel for the language  Goal: Be able to use a couple of CSS properties  CSS & HTML are commonly mixed into the same file  THIS IS GOING TO TAKE SOME GETTING USED TO, but you can do it!  Goal: Be able to identify which parts of a single file are the HTML parts (and obey HTML rules), and which are the CSS parts (and obey the CSS rules)  Goal: Be able to identify an external style sheet, and open / read the external stylesheet  Goal: Understand that in this class we’re going to mostly stick with ‘internal’ stylesheets, at least for now 7

Styles can be specified three ways : inside an HTML element (Inline Style) inside the head section of an HTML page (Internal Style Sheet) in an external CSS file (External Style Sheet) Tip: multiple external style sheets can be referenced inside a single HTML document. Cascading Order – YOU DO NOT NEED TO REMEMBER THIS!!! What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority: 1. Browser default 2. External style sheet 3. Internal style sheet (in the head section) 4. Inline style (inside an HTML element) So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the tag, or in an external style sheet, or in a browser (a default value). NOTE: If the link to the external style sheet is placed after the internal style sheet in HTML, the external style sheet will override the internal style sheet! 8

Inline Style Inline style does exactly what it sounds like, it adds a style or styles in direct line with the HTML code itself (i.e., it is "embedded" inline with the HTML code) An inline style loses many of the advantages of style sheets because the inline style mixes content with presentation. To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the font color and the left and right margins of a paragraph: THIS DEMONSTRATES THE INLINE METHOD OF CSS DECLARATION. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pellentesque iaculis luctus. Phasellus quis faucibus turpis. Ut convallis quam id risus mattis lobortis. Cras quis augue vulputate, laoreet mauris id, pharetra ligula. Curabitur placerat sem eros, non rhoncus justo sollicitudin eu. 9

Internal Style Sheet An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the tag, like this: p {margin-left:20px; margin-right:600px; color:red;} body {background-color: #ffff99;} 10

External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the tag. The tag goes inside the head section: An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a.css extension and given any name you choose appropriate to your design intentions (e.g., style.css). An example of a style sheet file is shown below: p {color:red; margin-left:20px; margin-right:600px; } body {background-color: #cccc66; } style.css index.html FYI: link rel is link relation and in our case it is a "stylesheet". There are other types of relations besides stylesheet, like author, help, license, search, to name a few. 11

 There’s an HTML file on the website which demonstrates this in the Lecture 02 example files  In this class we’ll mostly be using the internal style sheets (at least for now)  It’s still good to be able to recognize the others, too 12

Commenting HTML Comment CSS Comment /* Comment Goes Here */ 13

 Go to the exercises for today  Find the exercise for identifying CSS & HTML regions of a file  Do that exercise 14

Feel free to follow along with the slides, or check out the demo file (CSS_Selectors.html) on the course web page 15

CSS Syntax for internal & external stylesheets A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets or "squiggles": p {color:red; text-align:center;} 16

The element Selector Simply list the name of an element (such as p, or a, or li, or div, or span, or….) and ALL paragraphs/anchors/list items/divs/spans/etc will have that style applied. In the CSS p { background-color: azure; } In the HTML This paragraph has a very light blue background-it’s azure! 17

The id Selector: # Standards specify that any given id name can only be referenced once within a page or document. From my experience, ids are most commonly used correctly in CSS layouts. This makes sense because there are usually only one 'wrapper' per page, or only one menu, one banner, usually only one content pane, etc. What this means is, two selectors cannot us the same id. If you want to do that, then you would create and use a class (which we'll talk about a bit later). NOTE: Do NOT start an id name with a number! It will not work in Firefox. In the CSS p#wrapper { width:70%;  sets width of div in relation to the browser margin:0px auto; background-color: greenyellow; } In the HTML Some stuff gokes here google! etc. 18

The class Selector:. The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector is defined with a period or "dot":. NOTE: You can name a class anything you want, although it is recommended you give it a name according to its function. In the example below, all HTML elements with class="center" will be center-aligned: In the CSS.center {text-align:center;} In the HTML Rex Winkus's Portfolio Week 01 this is the stuff in the first week Week 02 this is the stuff in the second week W3Schools: Class vs IDClass vs ID 19

 Fun fact: the popular JavaScript library named jQuery uses CSS selector syntax to identify which part(s) of the page to dynamically modify using JavaScript. 20

21

Basic CSS Properties: color The color property specifies the color of text. In the CSS body {color:red;} h1 {color:#00ff00;}.ex {color:rgb(0,0,255);} In the HTML This is heading 1 This is an ordinary paragraph. Notice that this text is red. The default text- color for a page is defined in the body selector. This is a paragraph with class="ex". This text is blue. W3Schools: colorcolor ValueDescription colorSpecifies the text color. Look at CSS Color Values for a complete list of possible color values.CSS Color Values (W3Schools also has a list of the predefined color names (like red, green, blue, aqua, etc, etc.).list of the predefined color names inheritSpecifies that the color should be inherited from the parent element 22

The background-color Property The background-color property sets the background color of an element. background-color:green; W3Schools: background-colorbackground-color 23

HTML Color Codes Red/Green/Blue Hecadecimal Triplets abcdef Red/Green/Blue RGB Decimal Code X11 Color Names thistle, magenta, indigo, gray, grey HSL/HSV hue-saturation-lightness -value °, %, % Web Safe Colors VGA 256  216  (6 × 6 × 6 = 216) each from 00 to FF /* RGB model */ #F00 /* 3-digit shortchand hex form #rgb */ #FF0000 /* 6-digit traditional hex form #rrggbb */ rgb(255, 0, 0) /* integer range */ rgb(100%, 0%, 0%) /* float range 0.0% % */ /* RGB with alpha channel, added to CSS3 */ rgba(255, 0, 0, 0.5) /* 0.5 opacity, semi-transparent */ /* HSL model, added to CSS3 */ hsl(0, 100%, 50%) /* red */ hsl(120, 100%, 50%) /* green */ hsl(120, 100%, 25%) /* dark green */ hsl(120, 100%, 75%) /* light green */ hsl(120, 50%, 50%) /* pastel green */ /* HSL model with alpha channel */ hsla(120, 100%, 50%, 1) /* green */ hsla(120, 100%, 50%, 0.5) /* semi-transparent green */ hsla(120, 100%, 50%, 0.1) /* very transparent green */ 24

HTML Color Codes  You are expected to be able to change the color of stuff on in-class exercises, homeworks, etc from memory  You are expected to recognize the color property, and be able to use at least the words ‘red’, ‘green’, and ‘blue’ on quizzes & exams  You are NOT expected to remember anything else from the prior slide  Specifically, you will not be asked about hexadecimal#’s 25

Some Other Basic CSS Properties: font-family In the CSS [remember, that these class names can be anything you want].serif { font-family:"Times New Roman",Times,serif; }.sanserif { font-family:Arial,Helvetica,sans-serif; } In the HTML This is heading 1 This is heading 2 This is a paragraph. This is a paragraph. W3Schools: font-familyfont-family 26

Some Other Basic CSS Properties: font-size In the CSS h1 {font-size:250%;} h2 {font-size:200%;}.ften {font-size:10pt;}.bypixel {font-size:10px;}.f875em {font-size:0.875em;} In the HTML This is heading 1 This is heading 2 This is a paragraph. This is a paragraph. This is a paragraph. W3Schools: font-sizefont-size An "em" is a relative property based on the default font-size of the browsers, which is typically 16px. For example, this means that: 1em = (16 x 1) = 16px = 100% 1.25em (16 x 1.25) = 20px = 125% 0.75em (16 x 0.75) = 12px = 75% 2em (16 x 2) = 32px = 200% 27

Some Other Basic CSS Properties: font-style In the CSS [remember, that these class names can be anything you want].normal {font-style:normal;}.italic {font-style:italic;}.oblique {font-style:oblique;} In the HTML This is a paragraph, normal. This is a paragraph, italic. This is a paragraph, oblique. This is a heading1, oblique. W3Schools: font-stylefont-style 28

Some Other Basic CSS Properties: text-align The text-align property specifies the horizontal alignment of text in an element. In the CSS h1 {text-align:center} h2 {text-align:left} h3 {text-align:right} In the HTML This is heading 1 This is heading 2 This is heading 3 W3Schools: text-aligntext-align ValueDescription leftAligns to the left rightAligns to the right centerCenters the text justifystretches the lines so each line has equal width 29

Just for fun: Assorted Tips & Tricks Tips & Tricks HTML5 & CSS3 Readiness Chart Can I Use … ? Initializer Front End Tools for Workflow The ToolBox HTML/CSS Frameworks Blueprint Bluetrip Elements Malo CSS Tips & Tricks CSS3.me Generator CSS3Generator LayerStyles Gradient Editor Arrow Please Create CSS3 CSS Values 30

31