Styling Flashcards
Set font color to red
color: red;
Set font to “Gill Sans”
font-family: "Gill Sans", sans-serif;
Always provide web-safe web as a backup
Set font to bold
font-weight: bold
Set font size to 17px
font-size: 17px
Add solid red underline to text in p
text-decoration: underline solid red
Capitalize text in p
text-transform: capitalize
Center the text in p
text-align: center
Increase line height by 50%
line-height: 1.5
Break words in p
when necessary
word-break: normal;
What are web safe fonts
Web safe fonts: certain number of fonts that are generally available across all systems and can therefore be used without much worry.
Example: serif
, sans-serif
, monospace
How to set text shadow, what are the arguments
Arguments:
- Horizontal offset: positive values move the shadow right, and negative values left.
- Vertical offset: positive - up, negative - down.
- The blur radius (optional): a higher value means the shadow is dispersed more widely.
- Color (optional)
text-shadow: 4px 4px 5px red;
Change list marker (like ul
) to circle
list-style-type: circle;
Change list marker (like ul
) to 🥕 (unicode char) or set it’s color to red
\::marker { color: red; content: "🥕"; }
Change link color depending on it’s state. List all the stated and how to targe them.
-
Link: A link that has a destination (i.e., not just a named anchor).
:link
pseudo class.-
Visited:
:visited
pseudo class. -
Hover:
:hover
pseudo class. -
Focus: A link that is focused (e.g., moved to by a keyboard user using the Tab key or something similar, or programmatically focused using HTMLElement.focus()) —
:focus
pseudo class. -
Active: A link that is activated (e.g., clicked on but not released yet),
:active
pseudo class.
-
Visited:
ORDER IS IMPORTANT! (LoVe Fears HAte.)
a:link { color: #6900ff; } a:visited { color: #a5c300; } a:focus { color: #a5c300; } a:hover { color: #a5c300; } a:active { color: #a5c300; }
Different strategies for fitting images inside a box, how to set them.
-
cover
sizes the image down, maintaining the aspect ratio so that it neatly fills the box. As the aspect ratio is maintained, some parts of the image will be cropped by the box.-
contain
scales the image down until it is small enough to fit inside the box. This results in “letterboxing” as it is not the same aspect ratio as the box. -
fill
will fill the box but not maintain the aspect ratio.
-
object-fit: cover;
Table: size your columns according to the width of their headings (not how much content they contain)
```table {
table-layout: fixed;
}
~~~
Table: Prevent double border around cells
```table {
border-collapse: collapse;
}
~~~
Table: Implement zebra striping
tbody tr:nth-child(odd) { background-color: #ff33cc; } tbody tr:nth-child(even) { background-color: #e495e4; }