Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Comprog Css syntax selectors font and color properties

Total questions: 50

Worksheet time: 50mins

Name
Class
Date
1.

What is the basic syntax of a CSS rule?

a)

selector { property: value; }

b)

{ property: value; } selector

c)

selector value { property; }

d)

property: value; selector

2.

Which of the following is NOT a way to link a CSS stylesheet to an HTML document?

a)

Using the <link> tag in the <head> section

b)

Embedding an internal CSS using the <style> tag

c)

Using the <script> tag to import a CSS file

d)

Embedding an inline CSS directly within an HTML element using the style attribute

3.

What is a CSS selector?

a)

A keyword used to specify the value of a CSS property

b)

A code that specifies the HTML element, class or ID to which a particular style should be applied

c)

A declaration block that contains CSS properties and values

d)

A rule that defines the overall layout of a web page

4.

Which of the following is NOT a type of CSS selector?

a)

Element selector

b)

Class selector

c)

ID selector

d)

Function selector

5.

What is the difference between an ID selector and a class selector?

a)

ID selectors can be used multiple times on a page, while class selectors can only be used once.

b)

ID selectors have higher specificity than class selectors.

c)

Class selectors can be applied to one element, while ID selectors will affect all elements.

d)

There is no difference between ID selectors and class selectors.

6.

What is a declaration block?

a)

A set of CSS rules that defines the style of an HTML element

b)

A specific value assigned to a CSS property

c)

A keyword that specifies the type of selector

d)

A comment within a CSS stylesheet

7.

How do you separate multiple declarations within a declaration block?

a)

With a comma ,

b)

With a semicolon ;

c)

With a colon :

d)

with a new line character \n

8.

Which CSS selector targets all the <p>(paragraphs) on a webpage?

a)

#p

b)

.p

c)

p

d)

*

9.

In the following CSS code, what is the name of the section between the curly braces {}?

a)

Selector

b)

Declaration

c)

Property Name

d)

Rule

10.

What is the property name and value in the following declaration?

background-color: blue;

a)

Property name: blue; Value: background-color

b)

Property name: background-color; Value: blue

c)

Property name: background; Value: color: blue

d)

Property name: color; Value: background

11.

Which selector is used to style an element with a specific id in CSS?

a)

#text

b)

.text

c)

$text

d)

@text

12.

What is the purpose of the semicolon (;) in a CSS declaration block?

a)

To separate the property name and value

b)

To indicate the end of a declaration

c)

To enclose the declaration block

d)

To separate the selector from the declaration

13.

What is wrong with the following CSS code?

a)

Missing selector

b)

Missing semicolon after font-size

c)

Curly braces are incorrect

d)

color is not a valid CSS property

14.

How would you change the text color of all <h1> elements to blue using CSS?

a)

h1 { text-color: blue; }

b)

h1 { color: blue; }

c)

h1 { font-color: blue; }

d)

h1 { background-color: blue; }

15.

Which selector applies styles to all elements on a webpage?

a)

*

b)

.

c)

#

d)

;

16.

Which part of the following CSS rule is the selector?

a)

margin: 0;

b)

font-family: Arial, sans-serif;

c)

body

d)

{}

17.

Which of the following is an advantage of using external CSS?

a)

It allows for quick application of styles to a single element only.

b)

It keeps HTML and CSS completely separate, making the code easier to maintain.

c)

It can only be applied to a single webpage.

d)

It allows for styles to be applied inline directly within HTML elements.

18.

How do you link an external CSS file to an HTML document?

a)

<css href="styles.css">

b)

<link rel="stylesheet" href="styles.css">

c)

<script src="styles.css"></script>

19.

Where should internal CSS be placed in an HTML document?

a)

Inside the <head> tag, within <style> tags

b)

Inside the <body> tag, within <script> tags

c)

Inside a <div> tag, within inline attributes

d)

In an external .css file linked to the HTML document

20.

Which of the following is an example of applying inline CSS?

a)

<h1 style="color: blue;">Welcome to my website</h1>

b)

<link rel="stylesheet" href="styles.css">

c)

<style> h1 { color: blue; } </style>

d)

<div class="header">Welcome to my website</div>

21.

Which method of adding CSS would you use if you need to apply styles to a single element only and want to avoid creating a new class in internal CSS or editing external files?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

Browser Default Styling

22.

If a conflict occurs between inline, internal, and external CSS, which one will take priority?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

All methods will apply equally

23.

Which of the following is true about internal CSS?

a)

It can be reused across multiple pages.

b)

It is written directly in the HTML element's style attribute.

c)

It is defined within <style> tags in the <head> section.

d)

It is always more efficient than external CSS.

24.

You want to set the background color of a webpage to light blue. Which of the following CSS rules is correct?

a)

background-color: blue;

b)

background: lightblue;

c)

background-color: lightblue;

d)

color: lightblue;

25.

To set the text color of a paragraph to red, you should use which CSS property?

a)

font-color

b)

text-color

c)

color

d)

font-style

26.

Which property is used to change the font size of text?

a)

font-weight

b)

font-size

c)

font-family

d)

text-size

27.

You want the text in your headings to appear bold. Which CSS property should you use?

a)

font-style: bold;

b)

font-family: bold;

c)

font-weight: bold;

d)

font-bold: true;

28.

You are designing a webpage and want the text in your paragraph to be displayed in the font "Arial." If "Arial" is not available, you want the browser to use any sans-serif font. Which CSS declaration should you use?

a)

font-family: Arial;

b)

font: Arial, sans-serif;

c)

font-family: Arial, sans-serif;

d)

font-type: Arial;

29.

p { font-size: 16px; color: black; }

In the following CSS rule, which part is the declaration block?

a)

p

b)

{ font-size: 16px; color: black; }

c)

font-size: 16px;

d)

color: black;

30.

Which of the following is an example of a CSS property name and value?

a)

font-size: 16px;

b)

color { blue; }

c)

selector { font: Arial; }

d)

h1 { }

31.

Examine the code and identify which type of CSS is used:

What type of CSS is applied to the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

32.

Examine the code and identify which type of CSS is used:

What type of CSS is used to style the <p> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

33.

Examine the code and identify which type of CSS is used:

What type of CSS is used to style the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

34.

Examine the code and identify which type of CSS is used:

What type of CSS is used for the <p> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

35.

Examine the code and identify which type of CSS is used:

What type of CSS is applied to the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

36.

Examine the code and identify which type of CSS is used:

What type of CSS is applied to the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

37.

Examine the code and identify which type of CSS is used:

What type of CSS is used for the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

38.

Examine the code and identify which type of CSS is used:

What type of CSS is used for the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

39.

Examine the code and identify which type of CSS is used:

What type of CSS is used for the <h1> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

No CSS is applied

40.

Examine the code and identify which type of CSS is used:

What type of CSS is used to style the <p> element?

a)

External CSS

b)

Internal CSS

c)

Inline CSS

d)

Both Internal and Inline CSS

41.

What type of CSS selector is used for the #header rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

42.

What type of CSS selector is used for the .navbar rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

43.

What type of CSS selector is used for the #footer rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

44.

What type of CSS selector is used for the p rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

45.

What type of CSS selector is used for the #main-content rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

46.

What type of CSS selector is used for the #main-content rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

47.

What type of CSS selector is used for the * rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

48.

What type of CSS selector is used for the rule?

a)

Element Selector

b)

ID Selector

c)

Class Selector

d)

Universal Selector

e)

Grouping

49.

Which of the following is the correct syntax for a CSS rule?

a)

color: red; { body }

b)

body { color: red; }

c)

body ( color: red )

d)

{ color: red; } body

50.

What does a CSS declaration block contain?

a)

The property and its value

b)

The selector

c)

The HTML element

d)

The color scheme