Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant...

8
Introduction to CSS Chapter No: 03 “CSS-Fonts” Course Instructor: ILTAF MEHDI IT Lecturer, MIHE, Kart-i Parwan branch, Kabul CASCADING STYL E SHEET

Transcript of Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant...

Page 1: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Introduction to CSSChapter No: 03“CSS-Fonts”

Course Instructor:ILTAF MEHDI

IT Lecturer, MIHE, Kart-i Parwan branch, Kabul

CASCADING STYLE SHEET

Page 2: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Fonts

The following CSS properties will be described:1. Font-family2. Font-style3. Font-variant4. Font-weight5. Font-size6. Font

Page 3: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Font family [font-family]• The property font-family is used to set a

prioritized list of fonts to be used to display a given element or web page.

• If the first font on the list is not installed on the computer used to access the site, the next font on the list will be tried until a suitable font is found.

• An example of a prioritized list of fonts could look like this:

h1 {font-family: arial, verdana, sans-serif;} h2 {font-family: "Times New Roman", serif;}

Page 4: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Font style [font-style]

• The property font-style defines the chosen font either in normal, italic or oblique.

• In the example below, all headlines marked with <h2> will be shown in italics.

h1 {font-family: arial, veranda, sans-serif;} h2 {font-family: " arial", serif; font-style: italic;}

Page 5: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Font variant [font-variant]

• The property font-variant is used to choose between normal or small-caps variants of a font.

• A small-caps font is a font that uses smaller sized capitalized letters (upper case) instead of lower case letters.

h1 {font-variant: small-caps;} h2 {font-variant: normal;}

Page 6: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Font weight [font-weight]

• The property font-weight describes how bold or "heavy" a font should be presented.

• A font can either be normal or bold. • Some browsers even support the use of

numbers between 100-900 (in hundreds) to describe the weight of a font.

p {font-family: arial, verdana, sans-serif;}

td {font-family: arial, verdana, sans-serif; font-weight: bold;}

Page 7: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Font size [font-size]

• The size of a font is set by the property font-size.

• There are many different units (e.g. pixels and percentages) to choose from to describe font sizes.

h1 {font-size: 30px;} h2 {font-size: 12pt;} h3 {font-size: 120%;}

Page 8: Fonts The following CSS properties will be described: 1.Font-family 2.Font-style 3.Font-variant 4.Font-weight 5.Font-size 6.Font.

Compiling [font]• Using the font short hand property it is

possible to cover all the different font properties in one single property.

• For example, imagine these four lines of code used to describe font-properties for <p>:p { font-style:

italic; font-weight:

bold; font-size: 30px; font-family:

arial, sans-serif;

}

Using the short hand property, the code can be simplified:p { font: italic bold 30px arial, sans-serif; }

The order of values for font is:font-style | font-variant | font-weight | font-size | font-family