CSS Exam Sample Questions
CSS Exam Sample Questions
The @font-face rule to embed a web font named Cantarell is: '@font-face { font-family: Cantarell; src: url(‘Cantarell.woff’) format(‘woff’), url(‘Cantarell.ttf’) format(‘truetype’); }'. This declaration specifies the font name ('font-family'), and the 'src' attribute links to the font files with their respective formats ('woff' and 'truetype').
The RGB representation for the color red is 'rgb(255, 0, 0)'. This is because the RGB color model defines colors through the intensity of the red, green, and blue channels. For pure red, the red channel is at its maximum intensity (255), while the green and blue channels are set to 0, resulting in 'rgb(255, 0, 0)' .
In the HSL color model, the hue value represents the type of color and is measured in degrees on the color wheel (from 0 to 360). It affects the resulting color by determining where the color falls on the spectrum—red at 0 degrees, green at 120 degrees, blue at 240 degrees, etc. The hue value impacts the basic shade of the color before saturation and lightness are applied .
CSS comments are properly entered using the format /* comment */, where the comment text is enclosed between /* and */. This format ensures that the comment is recognized and does not affect the actual CSS styling .
The keyword 'important!' should be added to a CSS style property to override other styles and inheritance. This is done by appending '!important' to the CSS rule, ensuring it takes precedence over other conflicting styles .
The CSS style to display h1 headings in green text on a yellow background is 'h1 {color: green; background-color: yellow;}'. The 'color' property is used to set the text color to green, and the 'background-color' property sets the background of the element to yellow .
The 'h1' element's font size within a nested structure is computed by multiplying its parent element's font size by the 'em' value specified in the rule. For body {font-size: 16px;} and body > article {font-size: 0.75em;}, the font size for body > article > h1 {font-size: 1.5em;} becomes 0.75 * 16px = 12px for the article, then 1.5 * 12px = 18px for the h1 .
To apply styles only to paragraphs that are direct children of an 'aside' element, the correct selector format is 'aside > p'. This uses the child combinator (>) to ensure that only elements that are direct children, and not just descendants, are selected .
The style rule that removes underlining from anchors within a navigation list is 'nav a {text-decoration: none;}'. This rule targets all 'a' elements (hyperlinks) that are descendants of any 'nav' element, removing default text underlining set by browsers .
To style all 'blockquote' elements with the 'Reviews' class to be italicized and indented, the rule 'blockquote.Reviews { font-style: italic; text-indent: 3em; }' is correct. This styles all blockquote elements with the 'Reviews' class by setting 'font-style' to italic and 'text-indent' to 3em to increase indentation .