Presentation is loading. Please wait.

Presentation is loading. Please wait.

XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)

Similar presentations


Presentation on theme: "XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)"— Presentation transcript:

1 XHTML & CSS 2 By Trevor Adams

2 Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags) Attributes Document Types Document level elements – structure of an HTML document

3 Topics Covered XHTML Parent / Child Elements Hierarchical structure that facilitates styles that ‘cascade’ Block-level and inline elements

4 Topics Covered CSS Cascading Style Sheets Purpose of styles CSS levels 1, 2 and 3 Defining styles Understanding selectors Inheritance The box model Major CSS Concept

5 XHTML Standards compliant mark-up should be well formed and valid Hopefully you have become familiar with the validation Part of being well formed and valid is to have properly nested and appropriate elements The concept of parent / child elements has been used already Might not have noticed, elements of the bullet list are a good example

6 XHTML – Parent / Child The ‘eldest’ element in an XHTML document is An element is said to be a parent when it encompasses other elements An element is said to be a child when it is contained within another element is a child of is child to, making a parent is child to, which makes a parent also It is possible for an element to be both a child and parent

7 XHTML – Parent / Child Certain elements have to be children Particularly where the structure of an element demands this And must be a child of a element, logically and semantically Table cells could not exist validly outside of a table element

8 XHTML – Block / Inline Elements All elements in XHTML are rendered as either block-level or inline It is important to understand what these descriptions mean Assists with understanding XHTML validity Affords an understanding of CSS rules applied to each type

9 XHTML – Block-level Elements A block-level element is always as wide as its container It always forces new content onto a new line Examples of block elements, -,, They can contain other block level elements and / or inline elements

10 XHTML – Inline Elements Inline elements are contained within a block- level element and flow as part of the content Inline mark-up does not break on to a new line automatically (except the ) Examples of inline elements,,,,

11 Question? Is an element inline or block-level?

12 Cascading Style Sheets Introduction

13 What does CSS do? Allows to define rules to determine the appearance of mark-up We do not want appearance mark-up in our HTML files. Not necessary – for many reasons Think about it for a moment

14 Meaning and Appearance The XHTML document should contain the meaning It is the information that is paramount Design issues are subjective Not everyone can use a visual design People may not want the style you chose But what about my great design! Take pride in delivering a web site that is accessible first and looks good second CSS lets you accomplish both

15 CSS is good for you External CSS files make each of your HTML files smaller and efficient No need to repeat the formatting rules You can manage your site look and feel from one file No matter two or two hundred pages Concentrate on producing clean mark-up The information in the mark-up should make sense when there is no style attached Users should not have to rely on the style you create for them They may night have keen sense of style!

16 CSS is good for the user Pages are smaller, therefore faster to download A browser can easily cache a style sheet No need to keep retrieving it upon page requests Some browsers allow users to customise their experience with personal style sheets Let the user ‘use’ their computer the way they want to – do not force them into things they do not want

17 Format of CSS A rule is made with Selector – element(s) to reference Declaration – set of statements that associate an element display property with a value specified. Every declaration is in the format ‘property-name: value;’ A declaration may have one or more rules defined

18 Validation of CSS Similar to validating your (X)HTML pages you should validate your style sheets too Using the following validating tool online: W3C Validation Or this one: CSS

19 Where are we going with CSS We shall style our documents using CSS Also, control the screen layout using positional CSS But not this week grass hoppers! First we must master the basics Learn how to create dynamic effects without JavaScript, such as menu rollovers

20 CSS - Inheritance A major advantage of CSS – Inheritance Setting properties for parent elements Automatically passing them down to children E.g. setting font-family to Arial Has a knock on effect of setting child elements to the same No need to specify a rule for each child element also Can change the setting with one line in the CSS The more specific rules override the more general ones Nice and easy to see what is going on

21 CSS – The Box Model Everything in XHTML / CSS is treated as a box Both inline and block level elements The box is made up of Border Margin Padding

22 Box Model Margin – space between border and other boxes Border – line that marks the box boundary Padding – space between border and contained content

23 Summary XHTML concepts are important They define how you describe your information Remember, information is paramount, presentation is secondary Aim to achieve both, but presentation with information is generally useless CSS – Cascading Style Sheets Become familiar with the Box model and property inheritance Corner stone concepts of CSS

24 Where is it going? These topics are of little use to you when just listening about them Need to practice skill, learn the behaviour and develop using the parent/child and box model concepts mindset Engage with the tutorial material and learn to use these concepts in real examples and exercises Do not do, then forget. This is a skill which needs visiting many times over to see how it applies to different projects Examine any previous work and see how the techniques discussed here could be applied Think about the steps involved in turning an older standard / non-standard site into a professional job

25 Questions? Thank you for taking part!


Download ppt "XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)"

Similar presentations


Ads by Google