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. PHP 好用第三方库

    PHP 好用第三方库 whoops 更好的php错误报告库 [github]:https://github.com/filp/whoops Whoops是一个易于处理和调试错误的PHP库 .它提供基于 ...

  2. 二叉树 ADT接口 遍历算法 常规运算

    BTree.h   (结构定义, 基本操作, 遍历) #define MS 10 typedef struct BTreeNode{ char data; struct BTreeNode * lef ...

  3. Spring 注解学习

    @GetMapping(value = "/hello/{id}")//需要获取Url=localhost:8080/hello/id中的id值 public String say ...

  4. The Road to learn React书籍学习笔记(第二章)

    The Road to learn React书籍学习笔记(第二章) 组件的内部状态 组件的内部状态也称为局部状态,允许保存.修改和删除在组件内部的属性,使用ES6类组件可以在构造函数中初始化组件的状 ...

  5. express-session deprecated undefined resave option; provide resave option app.js

    nodejs使用express-session报错 代码如下 app.use(session({ secret: 'hubwiz app', //secret的值建议使用随机字符串 cookie: { ...

  6. 20155229 2016-2007-2 《Java程序设计》第一周学习总结

    20155229 2016-2007-2 <Java程序设计>第一周学习总结 教材学习内容总结 1~18章的提问: 第一章:怎样撰写Java才不会沦于死背API文件.使用"复制. ...

  7. 20155330 实验一《Java开发环境的熟悉》(Windows+IDEA)实验报告

    实验知识点 JVM.JRE.JDK的安装位置与区别: 命令行运行javac:java:javac -cp; java -cp: PATH,CLASSPATH,SOURCEPATH的设定方法与应用: 包 ...

  8. Java技术——Interface与abstract类的区别

    )抽象类是对类抽象,是面向整个类的自下而上的设计理念,一般是先有各种子类,再有把这些有关系的子类加以抽象为父类的需求.而接口是对行为的抽象,是面向行为的自上而下的设计理念,接口根本就不需要知道子类的存 ...

  9. 银行业务-Excel文件的拆分逻辑

    一.问题: 随着银行业务数据量的急剧增加,原始的人力统计数据已经不能满足要求, 需要开发一款可以实现自动化数据统计的系统平台,进行数据的采集.加工.过滤.统计.预测 其中数据采集方式又以[Excel] ...

  10. centos7下将java -jar命令运行一个项目做成systemd服务

    有些时候运行一个java项目在linux下通过一条简单的java命令即可,如: #nohup java -jar jenkins.war & ###这里为后台运行jenkins 在此背景下,j ...