1 / 21

CSS

CSS. Dynamic HTML. Cascading style sheets, HTML, DOM and Javascript. DHTML. Collection of technologies forming dynamic clients HTML ( content ) DOM ( data structure ) JavaScript ( behaviour ) Cascading Style Sheets ( presentation ). HTML ELEMENT. Standard PROPERTIES.

ember
Download Presentation

CSS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSS

  2. Dynamic HTML Cascading style sheets, HTML, DOM and Javascript

  3. DHTML • Collection of technologies forming dynamic clients • HTML (content) • DOM (data structure) • JavaScript (behaviour) • Cascading Style Sheets (presentation)

  4. HTML ELEMENT Standard PROPERTIES Standard METHODS Standard EVENTS This is not the complete listing. Standard COLLECTIONS

  5. CSS

  6. Cascading Style Sheets • Method for specifying properties for HTML elements • default and specific fonts, colours etc. • Allows easy modification of page styles • Style sheet can be modified rather than editing the html • Style sheet can be embedded in HTML or linked via an external file

  7. CSS Structure and Syntax • General syntax: Selector{ property:value; property:value;} • The selector is normally the HTML element you want to style. • Each declaration consists of a property and a value.

  8. CSS Structure & Syntax • CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly brackets • The comment syntax is just like in C-programming: • /* this is a comment */ • You can specify and apply CSS-style formatting to an HTML element either by using an ID selectoror a Class selector.

  9. Incorporating CSS There are three ways of inserting a style sheet: • External style sheet • Internal style sheet • Inline style

  10. 1. Incorporating CSS • 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. • The file should not contain any html tags. • Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section: <head><link rel="stylesheet" type="text/css" href="mystyle.css" /></head>

  11. 1. Incorporating CSS • Example: External style sheet mystyle.css • hr {color:red;} • p {color:orange;text-align:center;} • body {background-color:#d0e4fe;} myHTML.html • <head><link rel="stylesheet" type="text/css" href="mystyle.css“ ></head>

  12. 2. Incorporating CSS • Internal style sheet • Suitable when a single document has a unique style. • You define internal styles in the head section of an HTML page, by using the <style> tag, like this: • <head> • <style type="text/css"> • hr {color:red;} • p {color:orange; text-align:center;} • body {background-color:#d0e4fe;} • </style> • </head>

  13. 3. Incorporating CSS • Inline style sheet (Inside an HTML element) • An inline style loses many of the advantages of style sheets by mixing 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 shows how to change the color and the left margin of a paragraph: <p style="color:rgb(255,0,0);margin-left:20px"> Hello! </p> Avoid using the inline style!

  14. Cascading Order of Styles • Cascading multiple styles (the list is in increasing order of priority) • 1. Browser default • 2. External style sheet • 3. Internal style sheet (in the head section) • 4. Inline style (inside an HTML element) Note: If the link to the external style sheet is placed after the internal style sheet in HTML <head>, the external style sheet will override the internal style sheet! #4 has the highest priority.

  15. 1. Applying CSS to an HTML element • You can apply CSS-style formatting to an HTML element either by using an ID selectoror a Class selector. • ID SELECTOR • The id selector is used to specify a style for a single, unique element. • The id selector uses the id attribute of the HTML element, and is defined with a "#". • The style rule below will be applied to the element with id="para1": • Do NOT start an ID name with a number! It will not work in Mozilla/Firefox. • General Syntax: #ID-name { Property:value; Property:value; /*... and so on.. */ } ID selector application: <h1 id=”ID-name”> Internet programming </h1>

  16. 2a. Applying CSS to an HTML element • You can apply CSS-style formatting to an HTML element either by using an ID selectoror a Class selector. • 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 any HTML elements with the same class. • The class selector uses the HTML class attribute, and is defined with a "." • General Syntax: • .class-name • { • Property:value; • Property:value; • /*... and so on.. */ • } class selector application: • <h1 class=”class-name”> Internet programming </h1> • <p class=”class-name”> Dynamic HTML: CSS, HTML, DOM, Javascript </p>

  17. 2b. Applying CSS to an HTML element • You can apply CSS-style formatting to an HTML element either by using an ID selectoror a Class selector. • class SELECTOR • You can also specify that only specific HTML elements should be affected by a • class. • General Syntax: /* this class selector is only applicable to paragraphs*/ p.class-name { Property:value; Property:value; /*... and so on.. */ } class selector application: <p class=”class-name”> Dynamic HTML: CSS, HTML, DOM, Javascript </p>

  18. CSS Properties Index A continuously updated list of CSS properties can be found here: http://meiert.com/en/indices/css-properties/ http://www.w3schools.com/cssref/default.asp CSS Text: http://www.w3schools.com/css/css_text.asp CSS Demo: http://www.w3schools.com/css/demo_default.htm CSS Tables: http://www.w3schools.com/css/css_table.asp

  19. CSS Examples • body { • font-family: Georgia, "Times New Roman", Times, serif; • color: blue; • background-color: #FFFF00 } • Similarly any property can be specified and modified • You can define your own selectors • .myStyle {color: blue} • Use with a class=“myStyle” attribute in the element you want to modify You will find more examples in our website

  20. Center a Table with CSS CSS definitions: Centered, Fixed-width table • div.container { • width:98%; • margin:1%; • } • table.table1 { • text-align:center; • margin-left:auto; • margin-right:auto; • width:100px; • } • tr, td { • text-align:left; • } Applying your CSS styles in a table <div class="container"> <table class="table1"> ... </table> </div> http://www.granneman.com/webdev/coding/css/centertables/

  21. More Examples? • Maybe here: • http://www.granneman.com/webdev/coding/css/ • Or just search internet with keyword css. • Or you can use freely accessible css layout, css template, css menu, … that you can search on internet. • If you can save time on site layout, why waste it?

More Related