CSS – Cascading Style Sheets

Slides:



Advertisements
Similar presentations
CSS CSS stands for Cascading Style Sheets Styles define how to display HTML elements External Style Sheets can save a lot of work External Style Sheets.
Advertisements

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.
CSS(Cascading Style Sheets )
กระบวนวิชา 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.
Slide 1 of 62 CSS Pseudo-classes The syntax of pseudo- classes: selector:pseudo-class { property:value; } A pseudo-class is used to define a special state.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
CASCADING STYLE SHEETS CSS. 2 What CSS means?  CSS is an extension to basic HTML that allows you to style your web pages.  It separates the part that.
Basics of Web Design Chapter 6 More CSS Basics Key Concepts 1.
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
Web Design & Development Cascading Style Sheets (CSS)
CSE CASCADING STYLE SHEETS CSS Faculty of Computer Science and Engineering.
Lecture CSS: Cascading Style Sheets. What are Styles? Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
Slide 1 of 83 Table Borders To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td.
Cascading Style Sheets Example
Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
Cascading Style Sheets Billy Toy Cascading Style Sheets Syntax review How to Implement style sheets Background properties Text properties.
CSS Dvijesh Bhatt.
HTML/CSS Hyper Text Markup Language. CSS Cascading Style Sheets.
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.
1Computer Sciences Department. And use
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Cascading Style Sheets, pt 2 ECA 225 Applied Online Programming.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
WORKING WITH CASCADING
Doman’s Sections Information in this presentation includes text and images from
CIT Internet Based Programming Lecture notes: Week 4 Instructor:Dr. Tolgay KARANFİLLER.
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 External.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
آموزش طراحی وب سایت جلسه چهارم– سی اس اس 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Cascading Style Sheet Bayu Priyambadha, S.Kom. Definition Cascading Style Sheets (CSS) form the presentation layer of the user interface. –Structure (HTML)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
CHAPTER 3 CSS & CSS3 อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
Chcslonline.org Text –wrapping around Images. chcslonline.org To wrap text around an image, lets set up a style in our style sheet. open a new notepad.
Creating Your Own Webpage COSC Cascading Stylesheets Think of: HTML: content of your webpage HTML has tags CSS: presentation and appearance of your.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
CSS Class 2 -Add margins to elements on a page. -Set width and height of elements. - CSS shorthand properties for box model. -Style links. -Style tables.
CSS with XHTML Please use speaker notes for additional information!
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
©SoftMoore ConsultingSlide 1 Introduction to HTML: Cascading Style Sheets.
Lecture 2: Cascading Style Sheets (CSS) Instructor: Dr. M. Anwar Hossain.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
CSS properties Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
1 CSS محمد احمدی نیا 2 Of 21 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements 
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
Welcome To Website Design, Hosting And Management Prepared By Webdev Solution ip ,223,96.
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,
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
LEARNING CSS Techieweb Solutions Techieweb solutions.
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 solve a problem External.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
WebD Introduction to CSS By Manik Rastogi.
CSS.
( Cascading style sheet )
IS333: MULTI-TIER APPLICATION DEVELOPMENT
محمد احمدی نیا CSS محمد احمدی نیا
Kanida Sinmai CSS – Cascading Style Sheets Kanida Sinmai
Presentation transcript:

CSS – Cascading Style Sheets Lecture 4 Kanida Sinmai ksinmai@hotmail.com http://mis.csit.sci.tsu.ac.th/kanida

Styling HTML with CSS CSS stands for Cascading Style Sheets Styles can be added to HTML in 3 ways Inline - using a style attribute in HTML elements Internal - using a <style> element in the HTML <head> section External - using one or more external CSS files

Inline CSS Inline CSS uses style attribute e.g. <h1 style="color:blue">This is a Blue Heading</h1>

Internal CSS Internal styling is defined in the <head> section of an HTML page, using a <style> element. <!DOCTYPE html> <html> <head> <style> body {background-color:lightgrey} h1 {color:blue} p {color:green} </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

External CSS External styles are defined in an external CSS file, and then linked to in the <head> section of an HTML page: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

CSS file An external style sheet can be written in any text editor. The file should not contain any html tags. The style sheet file must be saved with a .css extension. An example of a style sheet file called ”styles.css”

CSS Syntax The selector points to the HTML element you want to style. The declaration block contains one or more declarations separated by semicolons. Each declaration includes a property name and a value, separated by a colon. Source: w3schools.com

Example: styles.css body { background-color: lightblue; } h1 { color: navy; margin-left: 20px;

CSS background background-color background-image background-repeat background-position

background-color: With CSS, a color is most often specified by: a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red" h1 { background-color: #6495ed; } p { background-color: rgb(255,0,0); div { background-color: green; See - http://www.w3schools.com/cssref/css_colornames.asp for further information

Background-image body { background-image: url("paper.gif"); }

Background Image - Repeat Horizontally or Vertically body { background-image: url("gradient_bg.png"); background-repeat: repeat-x; } To repeat an image vertically set background-repeat: repeat-y; To show image only once set background-repeat: no-repeat;

background-position body { background-image: url("img_tree.png"); background-repeat: no-repeat; background-position: right top; margin-right: 200px; } Values: left top left center left bottom right top right center right bottom center top center center center bottom

CSS Text Color body { color: red; } h1 { color: #00ff00; p.ex { color: rgb(0,0,255);

Text Alignment h1 { text-align: center; } p.date { text-align: right; p.main { text-align: justify; HTML FILE ---------------------------------- <h1>CSS text-align Example</h1> <p class="date">May, 2009</p> <p class="main">In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. 'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p>

Text Decoration h1 { text-decoration: overline; } h2 { text-decoration: line-through; h3 { text-decoration: underline; HTML FILE --------------- <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3>

Text Transformation p.uppercase { text-transform: uppercase; } p.lowercase { text-transform: lowercase; p.capitalize { text-transform: capitalize; <p class="uppercase">This is some text.</p> <p class="lowercase">This is some text.</p> <p class="capitalize">This is some text.</p>

Text Indentation p { text-indent: 50px; } <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. 'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p>

CSS Font p { font-family: "Times New Roman", Times, serif; }

Font style p { font-style: normal; } p.italic { font-style: italic;

Font Size h1 { font-size: 40px; } h2 { font-size: 30px; p { font-size: 14px;

Font size using em (16px=1em) The em size unit is recommended by the W3C. h1 { font-size: 2.5em; /* 40px/16=2.5em */ } h2 { font-size: 1.875em; /* 30px/16=1.875em */ p { font-size: 0.875em; /* 14px/16=0.875em */

Ways to specify size in CSS Pixels (px) Pt (1/72 inch) i.e. 12 pt font mm, cm, in em, ex (for font) Percent % (usually of the browser window dimension)

font-weight <p class="normal">This is a paragraph.</p> p.normal { font-weight: normal; } p.light { font-weight: lighter; p.thick { font-weight: bold; p.thicker { font-weight: 900; <p class="normal">This is a paragraph.</p> <p class="light">This is a paragraph.</p> <p class="thick">This is a paragraph.</p> <p class="thicker">This is a paragraph.</p> 100 200 300 400 500 600 700 800 900 Defines from thin to thick characters. 400 is the same as normal, and 700 is the same as bold

CSS Links a:link { text-decoration: none; background-color: #B2FF99; } a:visited { background-color: #FFFF85; a:hover { text-decoration: underline; background-color: #FF704D; a:active {

CSS Lists <p>Example of unordered lists:</p> <ul class="a"> <li>Coffee</li> <li>Tea</li> <li>Coca Cola</li> </ul> <ul class="b"> <p>Example of ordered lists:</p> <ol class="c"> </ol> <ol class="d"> ul.a { list-style-type: circle; } ul.b { list-style-type: square; ol.c { list-style-type: upper-roman; ol.d { list-style-type: lower-alpha;

CSS Lists - image ul { list-style-image: url('sqpurple.gif'); } <li>Coffee</li> <li>Tea</li> <li>Coca Cola</li> </ul>

CSS Table: border table, th, td { border: 1px solid black; } <tr> <th>Firstname</th> <th>Lastname</th> </tr> <td>Peter</td> <td>Griffin</td> <td>Lois</td> </table>

CSS Border Source: w3schools.com

Border-Collapse table { border-collapse: collapse; } table, td, th { border: 1px solid black;

Table Width and Height <table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Savings</th> </tr> <td>Peter</td> <td>Griffin</td> <td>$100</td> <td>Lois</td> <td>$150</td> <td>Joe</td> <td>Swanson</td> <td>$300</td> <td>Cleveland</td> <td>Brown</td> <td>$250</td> </table> table, td, th { border: 1px solid black; } table { width: 100%; th { height: 50px;

Horizontal Text Alignment th { text-align: left; } ** left, right, or center.

Vertical Text Alignment <table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Savings</th> </tr> <td>Peter</td> <td>Griffin</td> <td>$100</td> <td>Lois</td> <td>$150</td> <td>Joe</td> <td>Swanson</td> <td>$300</td> <td>Cleveland</td> <td>Brown</td> <td>$250</td> </table> table, td, th { border: 1px solid black; } td { height: 50px; vertical-align: bottom;

Table Padding td { padding: 15px; } To control the space between the border and content in a table, use the padding property on <td> and <th> elements: td { padding: 15px; }

Table color th { background-color: green; color: white; }

Border-width p.one { border-style: solid; border-width: 5px; } p.two { border-width: medium; p.three { border-width: 1px; <p class="one">Some text.</p> <p class="two">Some text.</p> <p class="three">Some text.</p> <p><b>Note:</b> The "border-width" property does not work if it is used alone. You must add the "border-style" property to set the borders first.</p>

Border-color p.one { border-style: solid; border-color: red; } p.two { border-color: #98bf21; <p class="one">A solid red border</p> <p class="two">A solid green border</p>

Border - Individual sides p { border-top-style: dotted; border-right-style: solid; border-bottom-style: dotted; border-left-style: solid; } <p>2 different border styles.</p>

Border - Shorthand property The border property is a shorthand for the following individual border properties: border-width border-style (required) border-color p { border: 5px solid red; }

CSS box model Content - The content of the box, where text and images appear Padding - Clears an area around the content. The padding is transparent Border - A border that goes around the padding and content Margin - Clears an area outside the border. The margin is transparent Source: w3schools.com

CSS Margin p { background-color: yellow; } p.ex { margin-top: 100px; margin-bottom: 100px; margin-right: 150px; margin-left: 50px; The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. <p>This is a paragraph with no specified margins.</p> <p class="ex">This is a paragraph with specified margins.</p>

CSS Padding p { background-color: red; } p.padding { padding: 25px 50px; <p>This is a paragraph with no specified padding.</p> <p class="padding">This is a paragraph with specified paddings.</p>

Padding - Individual sides p.padding { padding-top: 25px; padding-right: 50px; padding-bottom: 25px; padding-left: 50px; }

Padding - Shorthand property padding: 25px 50px 75px 100px; top padding is 25px right padding is 50px bottom padding is 75px left padding is 100px padding: 25px 50px 75px; right and left paddings are 50px padding: 25px 50px; top and bottom paddings are 25px padding: 25px; all four paddings are 25px p.padding { padding: 25px 50px; }

CSS Image img { opacity: 0.4; filter: alpha(opacity=40); /* For IE8 and earlier */ } img:hover { opacity: 1.0; filter: alpha(opacity=100); /* For IE8 and earlier */ <img src="klematis.jpg" width="150" height="113" alt="klematis"> <img src="klematis2.jpg" width="150" height="113" alt="klematis">

Image - float img { float: right; margin: 0 0 10px 10px; } <p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is that the image will float to the right in the paragraph.</p> <p> <img src="logocss.gif" width="95" height="84" /> This is some text. This is some text. This is some text. </p> img { float: right; margin: 0 0 10px 10px; }

CSS3 – Rounded corners p { background-color: yellow; With the CSS3 border-radius property, you can give any element "rounded corners". p { background-color: yellow; border-radius: 25px; }

Summary CSS CSS background CSS text CSS font CSS table CSS links CSS lists CSS image CSS margin CSS padding CSS border

Resources w3schools.com

Practical Please see practical #3 on my website