Great work! You've learned the basics of CSS structure and syntax. We'll continue to build on these basics as you learn more about CSS.

Let's review what you've learned so far:

1. A CSS selector targets an HTML element.

2. CSS declarations style HTML elements. Declarations must contain the following two things:

  • property - the property you want to style.
  • value - the value for the property you are styling.

3. CSS declarations must end in a semicolon (;)

4. A CSS rule consists of a CSS selector and the declarations inside of the selector.

5. Multiple element selectors can be used to style multiple elements at once.

6. Comments keep code easy to read and allow you to experiment with new code without having to remove old code.

7. CSS follows certain best practices for spacing and indentation:

  • One line of spacing between a selector and the opening curly brace.
  • No spacing between CSS declarations and the opening and closing curly braces of the CSS rule.
  • Two spaces of indentation for CSS declarations.
  • One line of spacing between CSS rules.

Color:

The current revision of CSS, CSS3 (at the time of this writing), introduces a new way to specify colors using HSL colors.

HSL stands for Hue, Saturation, and Lightness. Specifically, this is what each means:

  1. Hue - the technical term that describes what we understand as "color." In HSL, hue is represented on a color wheel. It can take on values between 0 and 360.

  2. Saturation - the amount of gray in a given color. In HSL, saturation is specified using a percentage between 0% and 100%. The percentage 0% represents a shade of gray, whereas 100% represents full saturation.

  3. Lightness - the amount of white in a given color. Similar to saturation, lightness is specified using a percentage between 0% and 100%. The percentage 0% represents black, whereas 100% represents white. 50% is normal.

You can use HSL colors in your CSS like this:

h1 { color: hsl(182, 20%, 50%); }

Notice that using HSL is very similar to using RGB.

Note: Because HSL is a part of CSS3, older browsers may not support it. In a later exercise, you'll learn how to work around support issues for colors.

RGB colors, hex color codes, and HSL colors offer web developers an extraordinary amount of color customization options. As these properties become more advanced, however, it's important to keep in mind that not all users browse the Internet with the same browser, let alone the same version of a given browser.

How does this affect web development? Newer revisions of HTML and CSS affect older browsers. Older browsers, over time, will become dated (possibly obsolete) and not be able to support newer CSS features. For example, many older browsers do not support RGBa, HSL, or HSLa.

Because of this, we must include redundant color options in our CSS code that can cater to a wide audience of different browsers.

Specifically, we can add multiple CSS color declarations, just in case a user's browser can't support a certain declaration.

h1 { color: rgb(22, 34, 88); color: rgba(22, 34, 88, 0.4); }

In CSS, the latter of multiple declarations takes priority. In the example above, if the user's browser supports rgba(), then that color will be applied to the heading. If it does not, then CSS will use the first rgb() color declaration, as a backup.

Using redundant declarations allow you to support as many users as possible across multiple versions of different Internet browsers.

reat job! You've learned how to style an important aspect of the user experience: color.

Let's review what you've learned so far:

  1. Foreground color refers to the actual color of an element, styled with the color property.
  2. Background color refers to the color behind an element, styled with the background-colorproperty.
  3. There are 147 named colors available.
  4. RGB and hexadecimal colors offer over 16 million color possibilities.
  5. HSL is a new way of defining colors in CSS3.
  6. You can modify the opacity of a color with RGBa or HSLa colors.
  7. Not all browsers support newer CSS features, like opacity or HSL, so additional declarations should be made to support a wide audience of users.
  8. There are many color picker resources available on the Internet to help you select specific colors, as well as provide colors in different formats.

[codecademy]css的更多相关文章

  1. Matplotlib数据可视化(3):文本与轴

      在一幅图表中,文本.坐标轴和图像的是信息传递的核心,对着三者的设置是作图这最为关心的内容,在上一篇博客中虽然列举了一些设置方法,但没有进行深入介绍,本文以围绕如何对文本和坐标轴进行设置展开(对图像 ...

  2. [Codecademy] HTML&CSS 第三课:HTML Basic II

    本文出自   http://blog.csdn.net/shuangde800 [Codecademy] HTML && CSS课程学习目录 --------------------- ...

  3. [Codecademy] HTML&CSS第八课:Design a Button for Your Webwite

    本文出自   http://blog.csdn.net/shuangde800 [Codecademy] HTML && CSS课程学习目录 --------------------- ...

  4. [Codecademy] HTML&CSS 第七课:CSS: An Overview

    本文出自   http://blog.csdn.net/shuangde800 [Codecademy] HTML && CSS课程学习目录 --------------------- ...

  5. [Codecademy] HTML&CSS 第一课:HTML Basic

    本文出自   http://blog.csdn.net/shuangde800 ------------------------------------------------------------ ...

  6. [codecademy]html&css

    1. HTML is the language used to create the web pages you visit everyday. It provides a logical way t ...

  7. [codecademy]fonts in css

    Great job! You learned how to style an important aspect of the user experience: fonts! Let's review ...

  8. CSS的未来

    仅供参考 前言 完成<CSS核心技术与实战>这本书,已有一个多月了,而这篇文章原本是打算写在那本书里面的,但本章讲解的内容,毕竟属于CSS未来的范畴,而这一切都还不能够确定下来,所以这一章 ...

  9. 前端极易被误导的css选择器权重计算及css内联样式的妙用技巧

    记得大学时候,专业课的网页设计书籍里面讲过css选择器权重的计算:id是100,class是10,html标签是5等等,然后全部加起来的和进行比较... 我只想说:真是误人子弟,害人不浅! 最近,在前 ...

随机推荐

  1. .NET Core On Liunx环境搭建之MongoDB

    伴随着.NET Core的开源,Liunx服务器才是.NET 的未来,公司前几天刚刚上新了一台Liunx服务器,我进行了一下环境的搭建,把经验分享出来. 服务器信息:  服务器用的是阿里云服务器,操作 ...

  2. docker inspect获取详细参数的两种方法

    docker inspect xx 返回的是一个json格式的数据 以下为部分返回值 [ { "Id": "706813b0da107c4d43c61e3db9da908 ...

  3. Debian使用dpkg安装MySQL

    说明 本文写于2017-10-03,使用MySQL 5.7,操作系统为64位 Debian GNU/Linux 8.6 (jessie). 安装 因apt仓库将mysql相关的包移除,需要自己去官网下 ...

  4. go学习之文件读取问题(需更新)

    go学习之文件读取问题(需更新) 一,问题: 今天做一个GO广度迷宫问题时,出现了一个奇怪的问题. 就是通过fmt.Fscanf()读取文件时,每行末尾多出一个0. 二,问题代码: 1,输入文件maz ...

  5. SQL SERVER循环遍历(普通循环和游标循环)

    1.首先需要一个测试表数据Student 2.普通循环 1)循环5次来修改学生表信息 --循环遍历修改记录--declare @i int   set @i=0while @i<5begin   ...

  6. 教你解决Xshell用SSH连接ubuntu总掉线该

    使用Xshell 5中的SSH连接ubuntu总是掉线,搞的自己束手无策,本集小编整理了一下原因及解决方法,现晒出来和大家分享一下,希望可以帮助大家. 1. Xshell客户端设置 将Keep Ali ...

  7. Flex4中的拖动技术

    下面列一个最简单的例子,在Flex中,拖动原来如此简单 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <?xm ...

  8. 20155301第十一周java课栈程序

    20155301第十一周java课栈程序 内容一:后序表达式: abcde/-f+ 内容二:根据填充以下代码: import java.util.Scanner; public class MyDCT ...

  9. PostgreSQL通过mysql_fdw访问MySQL数据库

    Mysql与PostgreSQL的安装过程省略. 为简便起见,把MySQL和PostgreSQL都安装在一个机器上,然后在此机器上(准确地说是在PostgreSQL运行的机器上)安装mysql_fdw ...

  10. Supervisor4.0和python2.7的crit问题,导致python进程阻塞

    1.问题原因 Supervisor高版本在守护python2.7的服务时,会crit并报错并倒至进程阻塞(python进程存在,但不在运行)的问题,一般会和字符集有关系 <type 'excep ...