Top Banner
Applying Text and Font Design using Classes, ID'S, Divisions, and Spans Engr. Esmeraldo T. Guimbarda Jr.
37

TM 1st quarter - 4th meeting

Jan 13, 2015

Download

Education

HTML: Applying Text and Font Design using Classes, ID'S,
Divisions, and Spans
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: TM   1st quarter - 4th meeting

Applying Text and Font Design using Classes, ID'S, Divisions, and Spans

Engr. Esmeraldo T. Guimbarda Jr.

Page 2: TM   1st quarter - 4th meeting

THE ID SELECTOR

The id selector is used to specify a style for a single, unique element. It uses the id attribute of the HTML element, and is defined with a "#".

Page 3: TM   1st quarter - 4th meeting

CSS CODE HTML CODE

Page 4: TM   1st quarter - 4th meeting

THE 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 many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "."

Page 5: TM   1st quarter - 4th meeting

CSS CODE

HTML CODE

Page 6: TM   1st quarter - 4th meeting

You can also specify that only specific HTML elements should be affected by a class. In the example below, all p elements with class="center" will be center-aligned:

Page 7: TM   1st quarter - 4th meeting

DIVISION

Division (or Div) is a block level HTML element used to define sections of an HTML file. A division can contain all the parts that make up your website including additional divisions, spans, images, text and so on. You define a division within an HTML file by placing the following between the <body></body> tags.

Page 8: TM   1st quarter - 4th meeting

example:

A division creates a line break by default. You can use both classes and IDs with a division tag to style sections of your website.

Page 9: TM   1st quarter - 4th meeting

SPAN

Span is similar to division except it’s an inline element. No line break is created when a span is declared

Page 10: TM   1st quarter - 4th meeting

CSS TEXT PROPERTIES

ColorYou can set the color of text with the following:color:value;Possible values are:• color name – example: (red, black…)• hexadecimal number – example: (#ff0000),

(#000000…)• RGB color code – example: (rgb(255, 0, 0))

(rgb(0, 0, 0))

Page 11: TM   1st quarter - 4th meeting

Text Transform

You can control the size of letters in an HTML element with the following:

text-transform:value;

Possible values are:

• none• capitalize• lowercase• uppercase

Page 12: TM   1st quarter - 4th meeting

Text Align

You can align text with the following:

text-align:value;

Possible values are:

• left• right• center• justify

Page 13: TM   1st quarter - 4th meeting

Text Decoration

You can decorate text with the following:

text-decoration:value;

Possible values are:

• none• underline• overline• line through• blink

Page 14: TM   1st quarter - 4th meeting

CSS FONT PROPERTIES

Font StyleYou can set the style of text in a element with the font-style property. Syntax:

font-style:value;

Possible values are:

• normal• italic• oblique

Page 15: TM   1st quarter - 4th meeting

Font Family

You can set what font will be displayed in an element with the font-family property. The font-family property can hold several font names as a “fallback” system. If the browser does not support the first font, it tries the next font. There are two choices for the values:• family name - The name of a font-family, like "times", "courier", "arial", etc.• generic family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace"

Page 16: TM   1st quarter - 4th meeting

example:

Note: Separate each value with a comma. If a font name contains white-space, it must be quoted. Single quotes must be used when using the "style" attribute in HTML.

Page 17: TM   1st quarter - 4th meeting

Font Size

You can set the size of the text used in an element by using the font-size property. Syntax:

font-size:value;

Possible values are:

• xx-large• x-large• larger• large

• medium• small• smaller• x-small• xx-small• length• % (percent)

Page 18: TM   1st quarter - 4th meeting

Activity:1. Open Notepad++. Click on Start > All Programs > Notepad++ folder > Notepad++.

Page 19: TM   1st quarter - 4th meeting

2. Create a new HTML file by clicking File > New, or pressing Ctrl+N on your keyboard.

Page 20: TM   1st quarter - 4th meeting

3. Save the file as “color_trio.html”.

To save the file, go to File > Save As. Type “color_trio.html” in the File name box. Select Hypertext Markup Language file in the Save as type selection menu. Save the file in your desktop.

Page 21: TM   1st quarter - 4th meeting

4. Type the basic skeleton code of an HTML document in color_trio.html. Define the title and the main heading as “Nutritious Color Trio” using the < title > tag and < h1 > tag respectively.

Page 22: TM   1st quarter - 4th meeting

4. Add three headings in the body section using the <h3> tag and define each of them as:

“< Color Group > Fruits and Vegetables”.

Under each heading, add one paragraph tag to be used for the list of fruits and vegetables.

Page 23: TM   1st quarter - 4th meeting
Page 24: TM   1st quarter - 4th meeting

5. Place the contents of the body by adding the list of fruits and vegetables according to their color in the paragraph tags. Give at least ten(10) for each color

Page 25: TM   1st quarter - 4th meeting

6. Add the style tag at the head section.

Page 26: TM   1st quarter - 4th meeting

7. Style the lists of fruits and vegetables and their corresponding headings using ID’s and divisions. Under the style tag, create three ID selectors and name them “ID1”, “ID2”, and “ID3”.

Page 27: TM   1st quarter - 4th meeting

8. In the ID selector, type the codes to modify the text and font properties of the lists of fruits and vegetables and their corresponding headings. Sample code:

#id{color:red;text-transform: capitalize;text-align: center;text-decoration: underline;font-style: italic;font-family: "Arial Black", "Arial Bold", Gadget, sans-serif;font-size: larger;}

Page 28: TM   1st quarter - 4th meeting
Page 29: TM   1st quarter - 4th meeting

9. Before each heading (except for the main heading), add a < div > tag. After each < /p > tag of the list of fruits and vegetables, add a < /div > tag. In the < div > tag, specify which ID you are going to use by typing:

< div id = “< ID selector >” >

Page 30: TM   1st quarter - 4th meeting
Page 31: TM   1st quarter - 4th meeting

10. Align the main heading to the center by using an inline style. Sample code:

< h1 style=”text-align: center” > Nutritious Color Trio < /h1 >

Page 32: TM   1st quarter - 4th meeting
Page 33: TM   1st quarter - 4th meeting

11. Style the main heading using classes and spans. Under the style tag, create class selectors and name them “main_heading”.

type the codes to modify the words “Color Trio” in the main heading. Sample code:

.main_heading{color:blue;text-align: center;font-style: oblique;font-family: "Rockwell Extra Bold", "Rockwell Bold", monospace;font-size: larger;}

Page 34: TM   1st quarter - 4th meeting
Page 35: TM   1st quarter - 4th meeting

12. Enclose the words “Color Trio” in < span >< /span > tags. Specify that you are going to use the “main_heading” class by typing:

< span class=”main_heading” >

Page 36: TM   1st quarter - 4th meeting

13. Save the file by clicking File > Save or pressing Ctrl + S on your keyboard. Open the file in a web browser.

Page 37: TM   1st quarter - 4th meeting

14. Open the HTML file to your browser by clicking Run > Lunch in Chrome or Lunch in Firefox on your Notepad++