WEB-DEVELOPMENT-FOUNDATION practice question 5 of 15

Which two color definitions are valid for use with CSS? Choose 2 answers.

Full set: 75 questions
Answer options
A: color: #FFFFFF; Correct answer
B: color: cmyk(255, 255, 255, 255);
C: color: rgb(255, 255, 255); Correct answer
D: color: 00FF00;
E: color: rgb(255, 255);
Correct Answer:
A. color: #FFFFFF;; C. color: rgb(255, 255, 255);
Explanation

In CSS, colors can be defined using several standard notations. The hexadecimal color value, prefixed with a hash (#), is a valid method. It uses six hexadecimal digits (0-9, A-F) to represent the red, green, and blue components of the color. The rgb() functional notation is also a valid method, which specifies the intensity of red, green, and blue as integer values ranging from 0 to 255. Both #FFFFFF and rgb(255, 255, 255) correctly define the color white using these standard, well-supported syntaxes.

Why Incorrect

B. color: cmyk(255, 255, 255, 255);
The CMYK color model is not a standard, widely supported color function for screen display in CSS. It is primarily used for print media.
D. color: 00FF00; This is an invalid hexadecimal color definition because it is missing the required leading hash (#) symbol. CSS parsers will not interpret it as a color.
E. color: rgb(255, 255);
The rgb() function requires three arguments representing the red, green, and blue channels. This syntax is invalid as it only provides two arguments. ---

References

1. Mozilla Developer Network (MDN) Web Docs: The CSS data type documentation explicitly lists valid color syntaxes.

Hexadecimal notation: States that the syntax is a # followed by 3, 4, 6, or 8 hex digits. (Reference for A and D).

rgb() notation: Specifies the syntax as rgb(R, G, B) where R, G, and B are numbers or percentages. (Reference for C and E).

The page does not list cmyk() as a standard color function. (Reference for B).

Source: MDN Web Docs, , "Syntax" section. Retrieved from https://developer.mozilla.org/en-US/docs/Web/CSS/colorvalue

2. W3C (World Wide Web Consortium) CSS Color Module Level 4 Specification: This is the official standard defining color in CSS.

Section 4.2. sRGB Colors: Defines the hexadecimal RGB notation (#RRGGBB).

Section 5.1. rgb() and rgba() functions: Defines the syntax for the rgb() function, requiring three values.

The specification does not include a general-purpose cmyk() function for sRGB displays.

Source: W3C Candidate Recommendation, 21 June 2022, "CSS Color Module Level 4", Sections 4.2 and 5.1. Retrieved from https://www.w3.org/TR/css-color-4/

3. MIT OpenCourseWare (OCW): Course materials for web programming cover fundamental CSS properties, including color definitions.

6.170 Software Studio, Lecture 3: HTML & CSS: This lecture introduces CSS basics, including the common ways to specify colors using hexadecimal codes (e.g., #ff0000) and RGB values (e.g., rgb(255,0,0)).

Source: MIT OpenCourseWare, 6.170 Software Studio, Fall 2005, Lecture 3 Notes. Retrieved from https://ocw.mit.edu/courses/6-170-software-studio-fall-2005/pages/lecture-notes/ (Specifically, lec3handout.pdf).

Scroll to Top