CSS Basics Flashcards
How do you make CSS comments?
Comments in CSS begin with a forward slash and an asterisk, and end with an asterisk and a forward slash. And everything that’s in-between those opening and closing characters is ignored by the browser.
Ex. /* Words here */
Why write comments in CSS?
Writing comments in CSS allows the coder to add explanatory notes or prevent the browser from interpreting parts of the style sheet.
How do you wholescale remove comments from CSS?
Command plus / on a Mac will remove all comments.
Command + /
What are CSS data types?
CSS data types are typical values (including keywords and units) accepted by CSS properties and functions.
What are the six absolute units in CSS when defining length?
px - pixels mm - millimeters cm - centimeters inch - one inch pt - point (which is 1/72 of an inch) pica - which is 12 points
Pixels (px) is the most common.
What is the difference between absolute units and relative units?
Absolute units don’t scale. Relative units and percentage units are more flexible, and will allow developers to lay out content independent of screen size and resolution, to scale with browser and screen size.
How do pixel lengths display on a standard display versus a high-density display?
Pixels (px) are relative to the viewing device. For low-dpi devices, 1px is one device pixel (dot) of the display. For printers and high resolution screens 1px implies multiple device pixels.
What are the advantages of using percentage units?
Percentages are relative to something else… so when you use percentages in CSS, the percentage value is measured relative to a parent element’s length.
SO, percentages are most useful when it comes to defining LAYOUT, especially when you want items to scale based on browser size or window size, per say.
What is the most commonly used unit for relative unit for font sizes?
It is the em unit. The em unit is a font relative unit that is calculated based on the parent element’s font size.
What is the default font size value for most browsers?
The default font size value is 16px
For most font sizes, how much will 1em equal to?
16px
2em = 32 px
3em = 48px
and so on and so forth
What does it mean that em-based values compound?
Em-based values are relative to their parent’s font-size value. This causes a compounding issue that makes their font-size values larger than the desired values.
For example, if I had a header that was font-size: 1.5em and an h1 within the header that was font-size: 2em, then the h1 would actually compound to 1.5emx2em=3em.
What is a rems? How does it help?
REM stands for root-m, and it is similar to an em unit, the only difference is that it is relative to the root element of the page, NOT THE PARENT element like EMs.
By root element, we are referring to the HTML element.
What are the three most common ways to describe color in CSS?
A predefined keyword, a hexadecimal value (#ff105e), or RGB function like rib(10, 13, 105).
How do you abbreviate hex values?
If the letters or numbers in a hex value duplicate, you can eliminate the duplicate letter or number.
ffccee
can become
fce
What is rgba?
RGBA has the ALPHA added to account for the alpha channel … the alpha channel sets the opacity of a color.
Alpha is added as a fourth value to the RGB value list and is added as a decimal. The higher the alpha, the higher the transparency.
How do you write hex values in CSS?
ff120e
You start with the hashtag and then follow with the 6 digit code of letters and numbers.
Ex.
How do you write RGB values in CSS?
You start with the letters RGB and then follow with parenthesis. Inside the parenthesis write a comma separated list with three numerical values.
Ex.
rgb(255, 107, 0)
How do you write RGB values in CSS with alpha?
You start with the letters RGB and then follow with parenthesis. Inside the parenthesis write a comma separated list with three numerical values. Add the alpha value as a fourth value, but add as a decimal point.
Ex.
rgba(255, 173, 59, .4)
What property allows us to control the horizontal alignment of text?
The text-align property.
What are the most commonly accepted values for the font-weight?
BOLD and NORMAL.
Note: All headings by default are set to bold.
What are web-safe fonts?
Web-safe fonts are fonts that can be displayed by all browsers on all computers.
You can define a webpage font as a fall-back font in case your original font doesn’t work on a person’s browser.
What is a CSS font stack?
A CSS font stack is a prioritized list of fonts that the browser will cycle through until it finds a font that is installed on a user’s system.