HTML Academy
Use of the background in typography
Typography11/20
Back to the list of tasks
  • 1. The font-size property
  • 2. Relative font size
  • 3. The line-height property
  • 4. Relative line height
  • 5. The font-family property
  • 6. The font-weight property
  • 7. The text-align property, horizontal text alignment
  • 8. The text-align property does more than just align text
  • 9. The vertical-align property, vertical text alignment
  • 10. Use of the background in typography
  • 11. The color property, text color
  • 12. Using margins to format the text
  • 13. The white-space property, space management
  • 14. Assignment of styles to preformatted text
  • 15. The text-decoration property, underlining as well as other effects
  • 16. The font-style property, italics
  • 17. The text-transform property, character case
  • 18. Shave space off the footer
  • 19. Summary of “Typography”
  • 20. Test: Designing an article
Using margins to format the text
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The color property, text color

Recall that the color of the text and background can be controlled using the color and background-color properties.

Now let’s take a detailed look at the values of these properties.

The color can be specified as a keyword (a full list of keywords is given in the specification). For example:

color: black; /* Black */
color: red;   /* Red */
color: white; /* White */

Another way to specify color is to indicate a hexadecimal value. This is what we used in the previous assignment. In this case, the color is formed from the red, green and blue components that are specified as a hexadecimal number that ranges from 00 to ff. In addition to the six-character hexadecimal format, the color code may also consist of a three-character triplet. In this case, the second character in the color components is duplicated first:

color: #000; /* Black, the same as #000000 */
color: #f00;    /* Red, the same as #ff0000 */
color: #fff;    /* White, the same as #ffffff */

If you do not want to deal with hexadecimal values, you can use the special rgb function, which specifies the color in a more familiar decimal format within the range of 0 to 255. This code also consists of three color components that are separated by commas:

color: rgb(0, 0, 0)       /* Black, which is the same as #000000 */
color: rgb(255, 0, 0)     /* Red, which is the same as #ff0000 */
color: rgb(255, 255, 255) /* White, which is the same as #ffffff */

The rgb function has an extended version: rgba. In this case, the code not only specifies the color: the last value in the code indicates the degree of opacity of the color, which is also known as its alpha. The value may vary from 0 (fully transparent) to 1 (fully opaque):

color: rgba(0, 0, 0, 0.5)      /* Black, 50% opaque */
color: rgb(255, 0, 0, 0.3)     /* Red, 30% opaque */
color: rgb(255, 255, 255, 0.9) /* White, 90% opaque */

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The website of a beginning coder</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <p class="page-title">Blog</p> <nav class="blog-navigation"> <a href="index.html">Return to home</a> </nav> </header> <main> <article> <h1>Day Eleven. Everything should be taken in moderation</h1> <p>I realized that I fed the cat too much. The cat decided to remove this item from the to-do list so that he would be able to walk across the snow and not fall through it.</p> <ol> <li><del>Feed the cat</del></li> <li><ins>Do not forget to eat yourself</ins></li> <li>Water the cactus</li> <li>Turn off the light</li> <li>Leave the house to run errands</li> </ol> </article> <aside class="partnership"> Your ad could go here </aside> </main> <footer> Website footer </footer> </body> </html>
CSS
body { padding: 0 30px; font-size: 16px; line-height: 26px; font-family: "Arial", sans-serif; color: #222222; background: #ffffff url("img/bg-page.png") no-repeat top center; } h1 { font-size: 24px; line-height: normal; } h2 { font-size: 20px; line-height: normal; } a { color: #0099ef; text-decoration: underline; } .page-title { font-weight: bold; font-size: 36px; line-height: 42px; font-family: "Verdana", sans-serif; text-align: center; } .avatar-container { text-align: center; } .avatar { border-radius: 50%; } .blog-navigation { margin-bottom: 30px; padding: 20px; color: #ffffff; background-color: #4470c4; border: 5px solid #2d508f; } .blog-navigation h2 { margin-top: 0; } .blog-navigation ul { padding-left: 0; list-style: none; } .blog-navigation li { margin-bottom: 5px; } .blog-navigation a { color: #ffffff; } .skills dd { margin: 0; margin-bottom: 10px; background-color: #e8e8e8; } .skills-level { font-size: 12px; text-align: center; color: #ffffff; background-color: #4470c4; } .skills-level-ok { background-color: #47bb52; } .partnership { color: #ffffff; background-color: #4a87fa; background-image: url("img/bg-partnership.svg"); } footer { margin-top: 30px; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Set the text color by assigning color the value #ff4400 in the del rule,
    2. and then for ins set it to a value of rgb(105, 178, 83).
    3. And in the rule for .blog-navigation change the value of the background color for background-color to rgba(68, 112, 196, 0.7).

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.