Basic CSS Flashcards
How do developers deal with style difference between browsers?
They often use what is called a CSS reset ( most popular of which is the Meyer reset) to zero out default styles and ensure a consistent user experience across browsers.
Another option is normalize.css, which is a CSS library that normalizes a subset of browser elements to be consistent between browsers.
What is the difference between CSS and HTML?
Whereas HTML is about structure and content (aka, the βcontent layerβ), CSS is about style and appearance (βpresentation layerβ).
What is CSS?
What is its syntax?
CSS (Cascading Style Sheets) is the language used to control the presentation layer. We use it to control the visual aspects of the content on a page: from fonts to color to size to animations and more.
Syntax: Target a set of elements with a CSS selector, and set properties and values as required by your presentational goal.
What is a ruleset?
Describes how input elements should look.
It consists of a selector, which is the elements that will be targeted by the declarations that follow.
What is a declaration block?
Follows the selector in a ruleset. It is a set of declarations contained in curly brackets ( {β¦} ). Within the block, each line is a separate declaration.
What is a declaration?
A declaration consists of a property and the value it is to be set to. The property name is followed by a colon, and the value is followed by a semicolon.
How do you write comments in CSS?
/* this is a comment */
T/F: When writing a ruleset, you want to keep your selectors as specific as possible.
Why?
FALSE.
Keeping selectors as non-specific as possible means that the settings can be reused on other targets if we decide they should have the same rules.
What is a pseudoclass?
A pseudo-class is used to target a special state of the element/document.
i.e. div.foo:hover
What is a pseudo-element?
A pseudo-element is used to style specified parts of the element/document.
i. e. p::first-letter
* *Note the double colon*
How do you link an external styelesheet in an HTML page?
In the head:
<link rel=βstylesheetβ type=βtext/cssβ href=β./css/main.cssβ>
What are engineers referring to with the saying βmaintaining the separation of concernsβ between HTML and CSS?
Itβs best practice to AVOID inline styling and use HTML only for describing structure and content and to use CSS to describe presentation.
Why should you avoid using inline styles?
Inline styles encode information about how an element should look directly into the HTML. This means you cannot reuse these styles on other elements. One of the advantages of CSS is reusable classes and classes are not possible with inline styles.
What is the benefit of isolating presentation into our CSS?
By isolating presentation into our CSS, our code will be more maintainable and extensible (that is, easier to apply presentation rules weβve set up in one place to new use cases).
What would be a reason for using a style element?
Improving page load speed.