Lab 1 Lab 2 Lab 3

Index
Multimedia

  1. What are different parts of a CSS style rule?
  2. What is the difference between a relative and absolute measure unit in CSS? Why are relative units preferred over absolute units in CSS?
  3. What are an element selector and grouped element selector in CSS? Provide an example of each.
  4. What are class selectors in CSS? What are id selectors in CSS?
  5. What are contextual selectors in CSS?

    Answers:

  1. There are multiple parts that make up a CSS style rule; it consists of a selector that links to the HTML element(s) that will be affected, with series of 'property:value' pairs following the selector. Each pair is called a delcaration, and all of the pairs grouped together is called a declaration block that is wrapped in curly brackets.

  2. Relative units are based on the value of something else, in respect to another element. Absolute units have a real-world size. It is recommended to use relative over absolute units to fit any browser.

  3. An element selector in CSS identifies one element that will be affected by the declarations specified in the rule, whereas a grouped element selector will affect multiple selectors that are separated by a comma.
    Element Selector example: h1{ property:value}
    Grouped Element Selector example: h1, h2{ property:value}

  4. Class selectors in CSS can be used to specify one style for multiple elements contained in that class on the page. All HTML tags have a class attribute, but you can also create your own classes with multiple elements of the same type. ID selectors can be used in CSS to specify a style for a single element only.

  5. Contextual selectors in CSS allow you to select elements based on their context or relation to other elements, also known as selecting elements based on their ancestors, descendants, or siblings.