Top Banner
Different Box elements • All our examples to date have been shown in terms of the box for H1 elements • Many other elements also have a box, including H2 elements
55

Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Different Box elements

• All our examples to date have been shown in terms of the box for H1 elements

• Many other elements also have a box, including H2 elements

Page 2: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 3: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 4: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• Cs 3314 got here on 20 october 2005

Page 5: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Box elements contd.

• A BODY also has a box

Page 6: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 7: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 8: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Box elements contd.

• The box for a BODY element has the full range of box attributes that we have seen including, for example, the PADDING attribute, which specifies the empty space between the border of the box and its content

Page 9: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 10: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 11: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Foreground (content) of a box

• We have discussed the BACKGROUND of a box quite extensively

• The foreground of the box is its content• The most typical content is text• Content has the attribute COLOR• In the following example, notice that the

boxes within the BODY inherit its value for the COLOR attribute

Page 12: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 13: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 14: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Overriding inherited values

• In the following, notice how the H2 element overrides the inherited COLOR from its parent, the BODY element

Page 15: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 16: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 17: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Box elements contd.

• Notice that even a P (paragraph) element has it box and that it inherits attributes, such as the COLOR of its content from its ancestral BODY

Page 18: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 19: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 20: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

The DISPLAY of an element

• Every element has a DISPLAY attribute

• Depending on the type of element the default value of its DISPLAY attribute is one of inline block list-item

• However, we can also set it to none which prevents the element from being rendered at all!

Page 21: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

DISPLAY contd.

• In the following example notice that the style sheet stops H1 elements being rendered at all, even though one is present in the document

Page 22: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 23: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 24: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

DISPLAY contd.

• The DISPLAY attribute is inherited by children elements from their ancestor

• In the following notice how setting the DISPLAY attribute of the BODY to none stops any of the document being rendered

Page 25: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 26: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 27: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

In-BODY styles

Page 28: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• It was explained earlier that the word “Cascading” refers to the prioritization given to the three levels of style sheet:– linked – in-head– in-body

with in-body styles being allowed to over-ride

in-head styles which can over-ride linked styles

Page 29: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• It was also stated that we should rarely need to use in-body styles

• However, we will consider them now, because there ARE times when they are needed

Page 30: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

General format of in-body style-sheets

• We can insert a stylesheet in the opening tag for any logical element for which it is possible to define a style

• The format is

< some-tag STYLE=“some-stylesheet”>

• For example:<H1 STYLE=“COLOR : red”>

Page 31: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• In the next slide, an in-body stylesheet for a specific H2 over-rides the general style specified for H2 in the in-head stylesheet

Page 32: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 33: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 34: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• There is, however, another way of achieving the same thing:– we can give a unique identifier to specific

elements in our document– and specify a style for this specific element in a

global stylesheet such as an in-head stylesheet or a linked style-sheet

Page 35: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• In the document on the next slide, we give the identifier balkanWars to the H2 which introduces the Balkan Wars

• In the in-head stylesheet we specify a style for the element with the identifier balkanWars

• We could have done the same thing in a linked style-sheet

Page 36: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 37: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 38: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• We can do the same thing for whole groups of elements, instead of just for individuals

• In the next slide, we give one style for all H2s but we then over-ride it with a different style for H2s which introduce African wars

Page 39: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 40: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 41: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• Of course, we use use both id and class in the same stylesheet

• In the next slide, we give a general style for all H2

• But we over-ride it with a style for H2s of class=african

• But we then over-ride part of that with a different BACKGROUND-COLOR for the H2 with id=biafra

Page 42: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 43: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 44: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Cs 3314 got here on 24 oct 2005

Page 45: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Letting Elements Float

• We can let elements float

• Consider the way that the headers float in the next slide

Page 46: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 47: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• This achieved by using the FLOAT attribute in the styles specified for the headers

• This attribute takes three values: left, right, and none

• none is the default value

• In the previous slide, the headers wee allowed to float on the left, as we can see from the document specification on the next slide

Page 48: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 49: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• In the next slide, we specify that the H1s will float on the left and the H2s on the right

Page 50: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 51: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 52: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

• We can use the FLOAT attribute on any element

• For example, the next document uses FLOAT =right for an IMG

Page 53: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 54: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.
Page 55: Different Box elements All our examples to date have been shown in terms of the box for H1 elements Many other elements also have a box, including H2 elements.

Other CSS Properties

• We have considered a wide range of CSS properties

• There are still others

• Please refer to the CSS web-site that is mentioned in the list of useful web-sites given in the web-site for this course

• I may expect you to know how to use them in future tests/exercises