Chapter 3 Designing Your Web Pages. Objectives What is CSS and Why it is needed How CSS looks and how to write it The different ways to add CSS code to.

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

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
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.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
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.
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.
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.
Chapter 8 Creating Style Sheets.
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
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.
4.01 Cascading Style Sheets
W EB S ITE L ECTURE C ASCADING S TYLE S HEETS. Cascading Style Sheets (CSS) Introduction CSS Objectives – Provide more control over web site content presentation.
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.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
Cascading Style Sheets Dreamweaver. Styles Determine how the HTML code will display Determine how the HTML code will display Gives designers much more.
CSS Dvijesh Bhatt.
Cascading style sheets (CSS)
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
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.
Chapter 12 Cascading Style Sheets: Part II The Web Warrior Guide to Web Design Technologies.
I NTRO TO CSS IAT100 Spring I NTRO TO CSS Covered in this lesson: Overview What is CSS? Why to use CSS? CSS for Skinning your Website Structure.
CSS: Cascading Style Sheets. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
CO1552 – Web Application Development Cascading Style Sheets.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
WRT235: Writing in Electronic Environments Basic CSS.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 10: A Deeper Look at CCS- Spring 2011.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Creating Your Own Webpage COSC Cascading Stylesheets Think of: HTML: content of your webpage HTML has tags CSS: presentation and appearance of your.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
CSS: Cascading Style Sheets Part II. Style Syntax.
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.
CSS Box Model. What is the Box Model? Each XHTML element appearing on our page takes up a "box" or "container" of space. Each box size is affected not.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
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…
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.
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.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
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.
WebD Introduction to CSS By Manik Rastogi.
4.01 Cascading Style Sheets
( Cascading style sheet )
>> Introduction to CSS
Cascading Style Sheets
Cascading Style Sheets (Layout)
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets Color and Font Properties
Training & Development
4.01 Cascading Style Sheets
Cascading Style Sheets III B. Com (Paper - VI) & III B
Web Programming and Design
Presentation transcript:

Chapter 3 Designing Your Web Pages

Objectives What is CSS and Why it is needed How CSS looks and how to write it The different ways to add CSS code to your ASP.NET pages and external files The numerous tools that VS offers you to quickly write CSS

CSS (Cascading Style Sheets) CSS is a language used for styling and design your web pages. CSS can be used to quickly change the appearance of your web pages. It is supported by all browsers, so it is not specific to.NET Very popular with designers of web pages. Used not just in enterprise applications, but heavily used in content delivery. mediums such as Blogs. CSS “rules” can be chained together for efficiency (more on that later).

But why is CSS needed? Before CSS, all the formatting was done with HTML tags and their attributes, which mixed both the data content that you wanted to display and how it should be displayed (presentation). For example: This is red text in an arial type face and slightly larger than the default text. What can be the problem here?

HTML shortcomings This is red text in an arial type face and slightly larger than the default text. Consider these problems: If we had this paragraph in multiple changes, any time we wanted to change th color we would have to do it in each instance. We can't dynamically change this formatting depending on a given scenario (i.e. colorblindness, visually impaired, etc.) Required duplication of formatting tags gives the page more data to load each time.

CSS to the rescue CSS addresses these problems by separating the data from the presentation. The html files will continue to be your data (content) but now they will refer to CSS files which dictated how the presentation should be handled. In addition, you can centralize your styling into a centralized CSS file, which means multiple HTML pages will use the presentation formatting from a central place and wont have to duplicate HTML presentation tags such as,,, etc. You can also embed CSS into your HTML element tags if needed. CSS is understood by all major browsers and it is the language you want to understand to design pages.

Intro to CSS Create a file named CssDemo.aspx In the markup, add the following after the closing tag h1 { font-size: 20px; color: Green; } p { color: #0000FF font-style: italic; }.RightAligned { text-align: right; }

Intro to CSS Inside the tag, add the following Welcome to this CSS Demo page CSS makes it super easy to style your pages. With very little code, you can quickly change the looks of a page. The CSS style gets applied to the appropriate elements.

Intro to CSS Output:

How does it work? The code block between the tags is called a rule or a rule set. A rule dictates how the elements affected by this rule set will behave. The elements are chosen by selectors. There are various different kinds of selectors. Inside each rule set are properties and values Selector -> h1 Rule Set Begins -> { property and value assigned-> font-size: 20px; color: Green; Rule Set End-> }

How does it work? For the above example, the selector affects all H1 elements The rule set affects those elements by changing the property “font-size” to a value of “20px”. Why is this useful from an organizational and efficiency perspective?

CSS – The language A CSS is a collection of rules. A rule a combination of a selector and one or more declarations. Each declaration is composed of a property and a value. To declare these rules, you create a style sheet which is placed either in between the tags in a markup file (.html, aspx.) – this is known as the inline way In a separate file that is then referred to by your markup (more on this later)

CSS – The language To be able to style an element on a page, a browser has to know three things: What element of the page must be styled? What part of that element must be styled? How do you want that part of the selected element to look? Hence our rules:h1{ font-size: 20px;OR font-size:20px; color: Green;} }h1 { color: Green; }

Selectors We use these to identify the elements we are going to be working with. The different type of selectors are: Universal Selector: Applies to all elements on the page Type Selector: Applies to the HTML elements specified in the rule ID Selector: Enables you to refer to a single element in the page by a unique ID Class Selector: Enables you to style elements through the class attribute.

Universal Selector Denoted by an asterisk (*) and gets applied to all the elements on your page. Use for Global settings. For example, assigned the same font to all your elements * { font-family: Arial; }

Type Selector Gets applied to all HTML elements of the same type. Not case sensitive H1 { Color: Green; }

ID Selector Uses the # (hash) symbol and refers to a single element on the page. The ID is used is the HTML ID given to an element (this is different than an ASP.NET control Id). It is case sensitive. #IntroText { font-style: italic; } This would affect this element: I am italic because I have the right ID.

Class Selector Can apply formatting to a number on unrelated elements by grouping them all into the same class. Case sensitive Rule uses a “.” (dot).Highlight { Color : Red; Font-weight: bold; } Affects the following: This is normal text but this is Red and Bold. This is also normal text but this link is Red and Bold as well.

Grouping Selectors Group selectors by separating them with a comma. For example: h1, h2, h3, h4, h5, h6 { color: Red; } Output: Any HTML headers H1 through H6 will be in red.

Combining Selectors Suppose that you want to target the styling of a specific element in a particular location. Given this html fragment, we want to style the underlined section to be BOLD My class is Attention, so my text is bold. My text is not bold, as it lacks the Attention class. I am NOT bold because I don't fall within MainContent.

Combining Selectors We can combine selectors (ID, type, class) to find the element we want. For the, class Attention shown below My class is Attention, so my text is bold. My text is not bold, as it lacks the Attention class. I am NOT bold because I don't fall within MainContent. We can create the following selector: section#MainContent p.Attention { font-weight: bold; } “section” finds the tag, “#MainContent” finds that id, “p” locates a paragraph inside the previous two elements and “.Attention” finds the element with class “Attention”.

Common Properties

Values The values that can be assigned depend on the type of property picked. Sometimes, there are multiple ways of assigning a value. For example: Color value “Red” has multiple values (Use HEX value) h1 { color: Red; } h1 { color: #FF0000; } h1 { color: rgb(100%, 0%, 0%); }

Values Other Possible values: Size units: px (pixel 1px = 1/96th of 1in) absolute measurement,Em (relative to the font size of the element) Font families Images: myimage.jpg Enumerations: Border-style has “solid”, “dashed” and “double” Values can be “relative” to the font size (em for example) or “absolute” always the same size (px for example). See for more info.

Using Shorthand CSS supports a shorthand format to make it easier to set some of the properties of elements. For example, the border property applies to all four sides of an HTML element and can be set individually for a side or for all sides at once. Shorthand for all sides:: border: 1px solid Black; Longhand for individual sides: border-top-width: 1px; border-top-style: solid; border-top-color: Black; border-right-width: 1px; border-right-style: solid; border-right-color: Black; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: Black; border-left-width: 1px; border-left-style: solid; border-left-color: Black;

Using Shorthand You can mix and match shorthand and longhand Suppose want all my borders 1 pixel solid black, except for my left border: border: 1px solid Black; border-left-color: Blue;

The CSS Box Model The CSS Box Model describes the way three important CSS properties are applied to HTML elements: padding, border, and margin.

The CSS Box Model Padding: The whitespace that surrounds the element within its border. Border: After the padding, this is the next whitespace. Margin: After the border, the last whitespace. Adding up these 3 properties add up to the space an element takes up in the page.

The CSS Box Model Given the following CSS, what is the total width?.MyDiv { width: 200px; padding: 10px; border: 2px solid Black; }... Element The Div has a width of 200px and a padding of 10px and a border of 2px. Final value?

Adding CSS to your Pages One way to add CSS is to use an external file Another Way is within the style tags h1 { color: Blue; } Last Way is to do it inline. This is white text on a black background.

CSS Overrides An important thing to consider is the way that the various types of style sheets override one another. If you have multiple identical selectors with different property values, the one defined last takes precedence. Example: h1 { color: Blue;  This is the style that would work on H1 }

Try it Out Complete Pg. 66 Complete Pg. 77 Complete Pg. 85

Summary In this chapter we covered: Understanding of how the HTML model is limited for styling and designing Learned how CSS are used to overcome such shortcomings. Reviewed how CSS syntax looks and behaves. Identified several selectors and how to work with rules. Reviewed the box model. Reviewed how to add CSS to your pages.