CSS in the presentation layer
IntroducidoEn esta lección
| English |
|---|
| inline style |
| class/klæs/ |
| cascade/kəˈskeɪd/ |
| property/ˈprɒpəti/ |
One file styles the site
- CSS builds the presentation layer. A shared stylesheet keeps every page in the same house style.
Stylesheets and inline styles 行内样式
h1 { color: navy; font-size: 28px; text-align: center; }
.highlight { background-color: yellow; font-weight: bold; }
- External stylesheet: a .css file attached to pages. Inline style:
<p style="color: red;">. - Comments:
/* … */.
Match each term to its meaning.
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Two places for styles.
Tag styles and classes 类
- A tag style (
h1 {…}) applies to every element of that type. - A class (
.highlight {…}) applies only where used:<p class="highlight">, on any kind of element.
Which applies only where it is used, such as <p class="highlight">?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
A tag style applies to every element of that type.
How is a comment written in CSS?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
HTML uses .
The cascade 层叠
- An inline style overrides attached stylesheets.
- Equally specific rules: the stylesheet attached last wins. Attach with relative paths.
Stylesheet p { color: black; }; one tag <p style="color: red;">: that paragraph is red.
The stylesheet sets p { color: black; }; one tag is <p style="color: red;">. What colour is that paragraph?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The inline style overrides the stylesheet.
Match each property to what it sets.
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Each property controls one feature.
Properties
| for | properties |
|---|---|
| background | background-color, background-image |
| font | font-family, font-size, color, text-align, font-weight |
| table | width, padding, border, border-collapse, vertical-align |
End each declaration with a semicolon. A missing ; can stop the next property 属性 working.
External stylesheets style many pages; inline styles one tag. Tag styles apply everywhere; classes only where used. In the cascade, inline beats attached, and the last attached sheet wins ties.
¿Qué salió mal? Solo el equipo del sitio ve esta información.