Untitled Quiz
59 Questions
100 Views

Untitled Quiz

Created by
@GrandDwarf5939

Questions and Answers

What does CSS stand for?

  • Creative Style Sheets
  • Computer Style Sheets
  • Colorful Style Sheets
  • Cascading Style Sheets (correct)
  • What are inline styles?

    Way to write CSS code directly within HTML code.

    What is the purpose of the style attribute in HTML?

    Add this attribute to your tag and set it equal to the CSS style you want applied.

    What is the element that contains CSS within an HTML file?

    <p>head</p> Signup and view all the answers

    When would you use the style attribute versus the <style> tag?

    <p>Use the style attribute for a single element; use the &lt;style> block for larger CSS.</p> Signup and view all the answers

    How do you define a CSS rule to set the font to Arial?

    <p>p { font-family: Arial; }</p> Signup and view all the answers

    Why should the structure (HTML) be separated from styling (CSS)?

    <p>They must be LINKED.</p> Signup and view all the answers

    What are the three attributes of the tag?

    <p>href, type, rel</p> Signup and view all the answers

    If a CSS file is stored in the same directory as your HTML file, how do you specify a relative path?

    <link rel='stylesheet' href='stylesheet.css'> Signup and view all the answers

    In a CSS file, what is a tag name?

    <p>The word or character between HTML angle brackets.</p> Signup and view all the answers

    What is a CSS selector?

    <p>Matches the HTML tag.</p> Signup and view all the answers

    What is a class attribute in HTML?

    <p>Used to point to a class in a style sheet.</p> Signup and view all the answers

    How do you select an element by its class attribute?

    <p>Use a period (.) prepended to the class name.</p> Signup and view all the answers

    How do you use CSS to select multiple classes and edit their HTML elements?

    <p>Write separate CSS rules for each class and include them in the element with a space.</p> Signup and view all the answers

    If an HTML element needs to be styled uniquely, what should you do?

    <p>Add an ID to the element.</p> Signup and view all the answers

    How do you add an ID to an element?

    <p>Use id attribute in HTML.</p> Signup and view all the answers

    In CSS, how do you define an ID name?

    <p>Use a hashtag (#).</p> Signup and view all the answers

    What are three ways to select HTML elements in CSS?

    <p>By their tag, by their class, by their ID.</p> Signup and view all the answers

    What is the purpose of CSS classes?

    <p>They are meant to be reused over many elements.</p> Signup and view all the answers

    How would you style two headlines with class='bold green' and class='bold blue'?

    <p>.bold.green, .bold.blue { ... }</p> Signup and view all the answers

    What's the difference between a class and an ID?

    <p>Classes can be used multiple times; an ID is unique to one element.</p> Signup and view all the answers

    What happens if you simultaneously call a class, a tag, and an ID?

    <p>The IDs override the styles of tags and classes.</p> Signup and view all the answers

    How do you write a class selector in your CSS file?

    <p>.name { ... }</p> Signup and view all the answers

    What is the best practice in CSS in terms of specificity?

    <p>Style elements using the lowest degree of specificity.</p> Signup and view all the answers

    What are the rankings of the selectors in CSS for specificity?

    <ol> <li>IDs, 2. Classes, 3. Tags.</li> </ol> Signup and view all the answers

    What is the only way to override an ID?

    <p>With another ID or with a !important tag.</p> Signup and view all the answers

    What is the best practice for creating CSS selectors in a large document?

    <p>Go from least to most specific.</p> Signup and view all the answers

    What is chaining in CSS?

    <p>Combining a class selector with a tag.</p> Signup and view all the answers

    How does CSS select nested HTML elements?

    <p>Use a combination of class selector and nested element syntax.</p> Signup and view all the answers

    How would you write a CSS entry for nested classes?

    <p>.layer1.layer2.layer3.layer4 { ... }</p> Signup and view all the answers

    What happens when two CSS rules target the same element with different specificity?

    <p>The rule with higher specificity will apply.</p> Signup and view all the answers

    What is !important in CSS?

    <p>It overrides any style, no matter how specific it is.</p> Signup and view all the answers

    How to add CSS styles to multiple selectors at once?

    <p>Separate each selector with a comma.</p> Signup and view all the answers

    What is a CSS declaration?

    <p>All the text inside the CSS selector.</p> Signup and view all the answers

    What two things does a CSS declaration consist of?

    <p>A property and a value.</p> Signup and view all the answers

    When is the semicolon used in CSS?

    <p>At the end of the declaration.</p> Signup and view all the answers

    What is the entire snippet of a CSS selector and body referred to?

    <p>The CSS rule.</p> Signup and view all the answers

    What does the font-family property do in CSS?

    <p>Changes the typeface of text.</p> Signup and view all the answers

    What is a CSS approved font stack?

    <p>A list of fonts recommended for use in CSS styles.</p> Signup and view all the answers

    What does the font-size property do?

    <p>Allows you to change font size.</p> Signup and view all the answers

    What does the font-weight property control?

    <p>Sets the text to 'bold' or 'normal'.</p> Signup and view all the answers

    What does the text-align property do?

    <p>Aligns text to the parent element.</p> Signup and view all the answers

    What’s the difference between foreground color and background color?

    <p>Foreground color refers to the color of the text; background color styles the element's background.</p> Signup and view all the answers

    What is opacity?

    <p>A measure of how transparent an element is.</p> Signup and view all the answers

    How do you specify a background image in CSS?

    <p>background-image: url('url.jpg');</p> Signup and view all the answers

    What is the correct syntax to style multiple unrelated selectors?

    <p>h1, p { ... }</p> Signup and view all the answers

    Which tag is used for CSS code directly in an HTML file?

    &lt;style> Signup and view all the answers

    How would you link a CSS file called main.css?

    <link rel='stylesheet' href='main.css'> Signup and view all the answers

    What is the correct syntax to select an HTML element inside another HTML element?

    <p>.main-list li { ... }</p> Signup and view all the answers

    Why does this inline styling fail? The color attribute is invalid.

    <p>It should be changed to style and set equal to color: red;</p> Signup and view all the answers

    Using the <style> tag for CSS helps accomplish what?

    <p>A clear separation between HTML and CSS.</p> Signup and view all the answers

    What is the main difference between inline styles and the <style> tag?

    <p>Inline styles modify HTML with style attributes; the &lt;style> tag is for dedicated CSS.</p> Signup and view all the answers

    What is an example of CSS selector specificity?

    <p>Specificity determines which styles apply when multiple are defined.</p> Signup and view all the answers

    Why does this tag attempt fail to style a paragraph? color='red' is an HTML attribute.

    <p>Correct way: use style attribute; color should be in CSS.</p> Signup and view all the answers

    What must happen for a stylesheet to style HTML code?

    <p>The stylesheet must be linked to the HTML page using the <link> tag.</p> Signup and view all the answers

    How would you change bullet points to squares in CSS?

    <p>.ingredients li { list-style: square; }</p> Signup and view all the answers

    How would you select elements of a specific class?

    <p>Chain the class selector with the element selector.</p> Signup and view all the answers

    How would you target a nested link using two classes?

    <p>.citation.external-link { ... }</p> Signup and view all the answers

    How would you write a selector for h1, h2, p, and li elements all at once?

    <p>h1, h2, p, li { font-family: Helvetica; }</p> Signup and view all the answers

    Study Notes

    CSS Basics

    • CSS stands for Cascading Style Sheets, used to style HTML elements.
    • Inline styles are applied directly within HTML tags, utilizing the style="" attribute.
    • Define styles within <style> tags placed in the <head> of an HTML document for larger stylesheets.

    Linking CSS to HTML

    • Use the <link> element to connect HTML and CSS files, requiring href, type, and rel attributes.
    • Relative paths can point to CSS files stored in the same directory as the HTML file.

    CSS Selectors

    • Selectors are utilized to apply styles to HTML elements based on their tag, class, or ID.
    • Class selectors are defined in CSS with a period (.), while ID selectors are defined with a hashtag (#).
    • Chaining allows the targeting of specific elements by combining tags and classes (e.g., p2.font).

    Specificity and Overrides

    • Styles are applied based on specificity ranking: IDs (most specific), classes, and tags (least specific).
    • IDs can override styles applied by class selectors or tag selectors. Use !important to enforce style overriding but do so sparingly.

    Writing CSS Declarations

    • CSS declaration consists of a property and a value (e.g., color: blue;).
    • Use a semicolon at the end of each declaration.

    Styling Properties

    • font-family: Specifies the typeface for text. Default is Times New Roman.
    • font-size: Changes the font size, often defined in pixels (px).
    • font-weight: Can be set to "bold" or "normal."
    • text-align: Aligns text within a parent element (left, center, right).

    Backgrounds and Opacity

    • Background color and image properties style an element's background. Use background-image: url("url.jpg") for images.
    • Opacity measures element transparency, ranging from 0 (fully transparent) to 1 (fully opaque).

    Selecting and Nesting

    • CSS can style nested elements using a space to denote hierarchy (e.g., .main-list li).
    • Target multiple unrelated selectors by separating them with commas (e.g., h1, .menu).

    Best Practices in CSS

    • Aim to write the least specific selectors first, progressing to more specific ones for easy future modifications.
    • Avoid unnecessary repetition by grouping similar styles using commas and targeting shared properties.

    Using CSS in HTML

    • Inline styles affect individual HTML elements via a style attribute, while the <style> tag encompasses broader CSS rules.
    • Specifying class attributes in HTML helps to point to class definitions in the associated CSS for styling.

    Common Mistakes

    • Ensure proper syntax in CSS; use CSS code inside <style> tags instead of HTML code.
    • For lists, CSS selectors can change bullet styles (e.g., .ingredients li { list-style: square; }).

    Additional Information

    • Keep the default font consistent and avoid using too many typefaces.
    • Use the correct format for fonts that consist of multiple words by enclosing them in quotes (e.g., "Courier New").
    • The CSS declaration block must remain free of HTML syntax for proper execution.

    Studying That Suits You

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

    Quiz Team

    More Quizzes Like This

    Untitled Quiz
    6 questions

    Untitled Quiz

    AdoredHealing avatar
    AdoredHealing
    Untitled Quiz
    37 questions

    Untitled Quiz

    WellReceivedSquirrel7948 avatar
    WellReceivedSquirrel7948
    Untitled Quiz
    15 questions

    Untitled Quiz

    TenaciousFeynman9892 avatar
    TenaciousFeynman9892
    Untitled Quiz
    99 questions

    Untitled Quiz

    WellConnectedComputerArt avatar
    WellConnectedComputerArt
    Use Quizgecko on...
    Browser
    Browser