CBSE Class 10 Computer Applications Question 35 of 37

Cascading Style Sheets (CSS) — Question 15

Back to all questions
15
Question

Question 15

What are three ways of creating style rules? Give examples of each.

Answer

The three ways of creating style rules are as follows:

1. Inline — Styles are embedded right within the HTML code they affect. For example,

<h3 style = "font.family = Arial ; color = red ">

2. Internal — Styles are placed within the header information of the web page and then affect all the corresponding tags on the page. For example,

<HEAD>
<STYLE TYPE = "TEXT/CSS">
h3 { font.family : Arial ; color : red ; }
</STYLE>
</HEAD>

3. External — Styles are coded in a separate document, which is then referenced from within the header of the actual web page. For example, let there be a CSS file named sample.css :

h3 { font.family : Arial ; color : red ; }

p { font.family : Times New Roman ; color : blue ; }

...and so on...

To link sample.css file to an HTML document, we use the <link tag in the following manner:

<HEAD>
<LINK REL = "STYLE SHEET" TYPE = "TEXT/CSS" HREF = "SAMPLE.CSS">
</HEAD>