CSS Fundamentals Quiz
30 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the order of values for the shorthand border property?

  • border-width, border-color, border-style
  • border-color, border-width, border-style
  • border-width, border-style, border-color (correct)
  • border-style, border-width, border-color
  • What is the CSS rule to set the border-width of a tag to 4px on the right side only, 2px on the bottom, 5px on the left, and 3px on the top?

  • border-width: 5px 2px 4px 3px;
  • border-width: 4px 2px 5px 3px; (correct)
  • border-width: 4px 5px 2px 3px;
  • border-width: 3px 5px 2px 4px;
  • What is the CSS rule to set the border-color of a tag to blue on the top, red on the right, green on the bottom, and black on the left side?

  • border-color: black blue red green;
  • border-color: blue red green black; (correct)
  • border-color: green red black blue;
  • border-color: red blue green black;
  • Which of these is the correct order for the cascading of style sheets? (Select all that apply)

    <p>Default browser style (B), Internal CSS (C), Inline style (D), External CSS file (E)</p> Signup and view all the answers

    If we inherit a font-family property from a parent tag with value "Verdana", and then set font-family in a child tag with value "Arial", what will be the font family used in the child tag?

    <p>Arial (D)</p> Signup and view all the answers

    What is the color of the word "One" in the following code snippet?

    p{ color: red; }
    One
    Two
    i{ color: blue; }
    

    <p>Red (D)</p> Signup and view all the answers

    In the following CSS code, which rule has the highest specificity?

    p.col{ color: red; }
    TEXT
    p#txtid{ color: blue; }
    

    <p>p#txtid{ color: blue; } (D)</p> Signup and view all the answers

    What is the color of the word "Two" in the following code snippet?

    p{ color: red; }
    One
    Two
    i{ color: blue; } 
    Three 
    p i{ color: green; }
    

    <p>Green (D)</p> Signup and view all the answers

    In the following code snippet, which rule will be applied to the element with the ID "txtid"?

    p.col{ color: red; }
    p#txtid{ color: blue; }
    p{ color: green !important;}
    

    <p>p{ color: green !important; } (C)</p> Signup and view all the answers

    Which approach does CSS use to determine the final style of an element?

    <p>Specificity and Inheritance (D)</p> Signup and view all the answers

    What is the main purpose of using a tableless design in web development?

    <p>To avoid using HTML tables for layout (C)</p> Signup and view all the answers

    Which CSS property is NOT used for positioning elements in a tableless design?

    <p>margin (C)</p> Signup and view all the answers

    What is the default position of the transform-origin property?

    <p>Center of the element (D)</p> Signup and view all the answers

    In a combined transform such as 'transform: translate(100px) rotate(45deg);', which transformation is applied first?

    <p>Translate (C)</p> Signup and view all the answers

    Which property allows for defining how far a 3D object is from the user?

    <p>perspective (B)</p> Signup and view all the answers

    What is the purpose of the transform-style property in 3D transformations?

    <p>To define how child elements are rendered in 3D space (C)</p> Signup and view all the answers

    Which of the following functions is NOT part of 3D transformations?

    <p>skewY (D)</p> Signup and view all the answers

    What is the effect of using a lower value for the perspective property?

    <p>It creates a more intensive 3D effect (B)</p> Signup and view all the answers

    Which of the following is NOT a keyword that can be used for the transform-origin property?

    <p>middle (A)</p> Signup and view all the answers

    In a transformation context, how are functions within the transform property arranged?

    <p>From right to left (A)</p> Signup and view all the answers

    Which of the following properties is primarily used to affect the visibility of an object's back face in 3D space?

    <p>backface-visibility (B)</p> Signup and view all the answers

    What property is used to specify the space between grid lines in CSS Grid Layout?

    <p>gap (D)</p> Signup and view all the answers

    Which property aligns a grid item inside a cell along the block (column) axis?

    <p>align-self (D)</p> Signup and view all the answers

    What is the default value for the flex-wrap property in CSS Flexbox layouts?

    <p>nowrap (D)</p> Signup and view all the answers

    Which of the following values can be used with the justify-content property?

    <p>flex-start (C)</p> Signup and view all the answers

    What property in CSS Flexbox is used to establish the main axis direction?

    <p>flex-direction (B)</p> Signup and view all the answers

    What does the align-content property control in CSS Grid Layout?

    <p>The overall alignment along the block axis (A)</p> Signup and view all the answers

    Which property would you use to align all items in a grid container to the center along the row axis?

    <p>justify-items (C)</p> Signup and view all the answers

    In CSS Flexbox, which value of the flex-direction property allows flex items to be arranged in a column going from bottom to top?

    <p>column-reverse (C)</p> Signup and view all the answers

    How does the align-items property affect grid items in CSS Grid Layout?

    <p>Aligns all items along the block axis (D)</p> Signup and view all the answers

    Study Notes

    Cascading Style Sheets (CSS)

    • CSS is a stylesheet language used to style HTML content
    • All visual layout of HTML pages should be done using CSS
    • Advantages include separating content from appearance, more compact code, better control over visual layout, defining different layouts to different devices and updating visual appearance of several documents simultaneously
    • A style sheet is a set of rules that indicates how to display HTML content
    • CSS syntax uses a selector, followed by curly brackets {} containing rules
    • CSS rules use property: value; pairs
    • CSS examples include changing font family, adding underlines and colors to tags, and various ways of applying styles

    Applying CSS

    • There are three ways to apply CSS rules to an HTML document:
      • Inline: using the style attribute on an HTML tag
      • Internal: using a <style> tag
      • External: using a tag to an external file

    CSS Units

    • CSS offers various units for expressing length
      • Absolute units: px (pixel), pt (point), pc (pica), cm, mm, in
      • Relative units: %, em
    • px typically matches a screen dot, pt is similar to px but used for print, pc equals 12pt, em equals the current font size

    CSS Colors

    • CSS has several methods to define colors
      • Reserved words (e.g., gray, green, blue)
      • Hexadecimal numbering (#RRGGBB)
      • rgb function (rgb(red, green, blue)
    • All of these methods represent the same color

    CSS calc Function

    • The calc() function performs calculations for property values
    • Syntax: calc(expression)
    • Operators include +, -, *, /

    CSS Selectors

    • Only the tag defined in the rule is affected by a type selector (e.g., p{ opacity:0.5; })

    • The universal selector matches the name of any tag (e.g., * { font-family: "Times New Roman"; })

    • Class selectors format layout on particular areas, they require a "class" attribute

      • Examples of class selector (.question { font-weight: bold; }), (.answer { font-style: italic; })
    • ID selectors are similar to class selectors but are case-sensitive and have a unique attribute value in the HTML document

      • Example ID selector (#heading_red { color: red; })
    • Descendant selectors apply properties only if the tags are encapsulated (e.g., div p { text-decoration: underline; } )

    • Pseudo-classes add effects to certain elements (e.g., a:hover { color: #FF00FF; }, a:visited {color: #00FF00; })

    • Anchor Pseudo-classes can use attributes like :link, :visited, :hover, :active

    • Form pseudo-classes select form controls such as input:focus, input:valid, input:invalid, input:required, input:optional , input:read-only, input:read-write, radio:checked.

    • Other pseudo-classes/pseudo-elements define the nth-child (e.g., p:first-child ) or nth-last-child element.

    CSS Selector Operators

    • Certain patterns and operators combine CSS elements -A[attr] - sets an attribute value, A[attr=val] - set exact values, A[attr~=val]- contains exact value, A[attr^=val]- begins with val and more

    CSS Grouping Selectors

    • Applying the same properties to multiple selectors simultaneously
      • Examples (h1, span.effect, p { font-family: "Times New Roman”; });

    CSS Background

    • Background colour is specified with background-color followed by a hex code or a color name
    • Background image is specified with background-image: url("image.jpg")
      • Additional options include no repeat, repeat-x, repeat-y, repeat.
    • Background-attachment is used to control how background image scrolls with the page (fixed or scroll)
    • Background-position controls the starting position of the background image. It can be specified in pixels or with keyword values like left, top, center.

    CSS Fonts

    • Font family specifies a fallback font
    • Other properties like font-style, font-variant, font-weight, font-size specify different styles you can apply to fonts

    CSS Text

    • text-indent: indents the first line of a paragraph
    • text-align: justifies, aligns left, right, center
    • text-decoration: underlines, overlines, line-through, blink
    • letter-spacing: space between characters
    • text-transform: capitalizes, uppercases, lowercases
    • margin: specifies outer spacing around blocks (e.g., 10%)
    • margin-left: specifies indent (e.g., -6%)

    List Markers

    • List markers can be changed for unordered and ordered lists using the list-style-type property
      • For unordered lists, values include none, disc (default), circle, and square
      • For ordered lists, values include none, decimal (default), lower-alpha, lower-greek, lower-roman, upper-alpha, and upper-roman

    Shorthand Properties

    • Several properties can be combined into a shorthand version
      • Example: border: 2px dashed blue

    Border Width and Order

    • Values can be used clockwise (example: border-width: 4px 2px 5px 3px); //top, right, bottom, left).
    • Order is important for border-color.

    CSS - Important Concepts

    • Cascade order of default browser style, external CSS files, internal CSS and inline styles.
    • Cascading means that a style defined further down in the layers takes precedence over earlier ones
    • Style sheet can import rules from other sheets

    CSS Inheritance

    • Tags in a hierarchy inherit characteristics of the parent elements
    • Both properties (like font-family, font-size and color) will be inherited from the parent elements

    CSS - Rules Priority

    • More specific selectors have higher priority
    • The rules with higher specificity independently of the order in them, take precedence

    CSS - Rules Specificity

    • Specificity is a calculation used to determine which rule takes precedence when identical properties are specified in different styles
    • It depends on the number of ID’s, classes and tags

    and Tags

    • and help to format layouts
    • uses block-level organization
    • uses inline organization
    • They are independent of other tags

    Display vs Visibility

    • display: none removes an element from the page
    • visibility: hidden only hides an element, leaving the space
    • visibility: collapse is a specific property for elements in a multi-row layout

    Box Model

    • HTML elements can be represented as boxes
    • The box model consists of margins, borders, padding and content

    Box Model - Dimensions

    • Values (px, percentage) provide width and height dimensions

    Box Model - Margin

    • Sets outer spacing around blocks
    • Use keyword values like top, right , bottom and left or comma separated values

    Box Model - Padding

    • Sets inner spacing within blocks
    • Use keyword values like top, right , bottom and left or comma separated values

    Box Model - Borders

    • Adds visual borders to elements
    • Values in shorthand order; top, right, bottom, left
    • Use keywords like dotted, dashed, or solid, thickness

    Box Model - Borders and Shadow

    • Sets radius of corners (top, right, bottom, and left)—shorthand
    • Attaches shadows of set thickness/color

    Box Model - 2D and 3D Transformations

    • Applies transformations like rotate, scale, skewness etc
    • It's possible to use multiple CSS transformations in a composite transform.

    Transform Origin

    • Sets fixed point for transformations
    • Values can be lengths in pixel/percentage or with keywords (top, bottom left, right, center)

    Combining Transforms

    • CSS applies transform functions in order from left to right

    Browser Support

    • Lists browser prefixes and versions to ensure compatible stylesheet with different browsers and versions

    3D Transformations

    • Supports transformations along the z-axis
    • New properties like scale3D, translateZ, rotate3D, rotateX, rotateY, rotateZ, matrix3D, perspective, transform-style, backface-visibility

    perspective Property

    • Creates a 3D perspective effect for 3D objects
    • perspective function applies perspective to child elements only
    • perspective property gives a 3D space around child elements

    transform-style Property

    • Specifies how nested elements appear during 3D layout
    • The flat value means child elements will not inherit the 3D position of their parent
    • Preserve-3D means child elements will inherit 3D position of their parent

    backface-visibility Property

    • Determines whether the back side of an element is visible or hidden

    transition Property

    • Applies smooth transitions between CSS property values
    • Can specify different transitions for different properties
    • Transition duration represents the time for the transition to complete, timing-function defines how transition completes (e.g., slow, fast, or both), and delay sets delay period

    @keyframes Rule

    • Creates a set of styles applied at different points of an animation
    • Defines styles that should be applyed during the animation (from, to, intermediate styles).

    animation Property

    • Defines the style and behavior for animations on elements
    • It controls the animation name, duration, timing function, delay, iteration count (how many times the animation plays), direction (e.g. forwards), fill mode (e.g. both), and play state (e.g. paused).

    Fonts

    • Properties (font-family, font-size, font-weight, font-width, font-style) control the appearance of text.
    • font family supports fallbacks when the browser doesn't support some type of font.

    Text

    • Property description to help specify text color (using RGB or hex), line-height, text decoration, alignment, indentation, capitalization, and word/letter-spacing in CSS.

    Color

    • Specifies background-color, text-color, and opacity (used to determine transparency of element)

    Background

    • Properties used to define background aspects (color, image, repeat, attachment, position).
    • It defines various properties including color, image, repeat, and position

    Tables

    • Property for defining table layout algorithm (auto or fixed).
    • Also define whether and how table borders collapse/are separated and whether or not to display empty table cells
    • Describes how the caption is placed

    Lists

    • Properties (list-style-type, list-style-image, list-style-position, list-style) to customize list appearance (type, image, position)

    Box Model - Width and Height

    • Properties that define the width and height of a box (using values for px and percentage)

    Box Model - Margin and Padding

    • Defines the margins and paddings in a box using keyword values

    Responsive Design

    • Defines a way to create websites that look good across different devices (using grids, media queries, and frameworks).
    • A technique used to create a site that looks good across different devices (e.g. computers, tablets, phones etc)
    • It also includes several style practices for handling different screen sizes
    • Use of CSS media queries to add different styles to handle diverse screen sizes (e.g. to scale the website for different device sizes).

    CSS Media Queries

    • Used to adapt styles to fit different media and devices
    • Includes values such as print, screen, speech, and more properties
    • This is about adjusting styles for different environments (e.g., printing, different sizes of screens).
    • Consists of a media type and expressions
    • Media queries enable dynamic layout of webpages for various physical devices

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    CSS PDF

    Description

    Test your knowledge on the fundamental concepts of CSS in this interactive quiz. Covering properties such as border, font-family, color specifications, and specificity, it is designed for both beginners and advanced learners. See how well you understand cascading style sheets!

    More Like This

    CSS Properties Quiz
    6 questions
    CSS Properties and Selectors Quiz
    6 questions

    CSS Properties and Selectors Quiz

    AdulatoryWildflowerMeadow avatar
    AdulatoryWildflowerMeadow
    CSS Properties for Customization
    40 questions
    Use Quizgecko on...
    Browser
    Browser