Previous task
Introduction to HTML and CSS12/13
Back to the list of tasks
  1. 1. Let's Go!
  2. 2. CSS in action
  3. 3. Consolidation
  4. 4. HTML basics
  5. 5. Single HTML tags
  6. 6. Attributes of HTML tags
  7. 7. Looking for errors in HTML
  8. 8. Basics of CSS
  9. 9. Other ways to connect CSS
  10. 10. CSS selectors
  11. 11. CSS classes
  12. 12. CSS properties and values
  13. 13. Looking for errors in CSS
Nest task
  • Courses
  • Sign up
  • Log in

Loading...
It will be ready in a few seconds.

  • Theory
  • Theory

CSS properties and values

So, the CSS language consists of selectors and properties. Selectors specify which elements to apply styles to, and properties specify how to display the elements.

There are a huge number of CSS properties that affect almost all aspects of element display. Each property corresponds to a specific set of values.

Some values are set using text constants, e.g. red, bold, others using numeric values: 12px, 120%, and so on.

The power of styles is that you can quickly and flexibly change the appearance of the elements you want, especially when you use classes. For example, to cross out the text of all the studied themes in an outline, you only need to add one line of CSS:

.completed {
  color: green;
  text-decoration: line-through;
}

And all tags with the .completed class will be displayed with the text crossed out. Now imagine how long it takes to do the same thing using inline styles when there are more than a hundred paragraphs in an outline.

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html> <head> <title>CSS classes</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Course outline</h1> <p class="completed">Paired tags.</p> <p class="completed">Single tags.</p> <p class="completed">Tag attributes.</p> <p class="completed">Inline styles.</p> <p class="in-progress">External Styles.</p> <p class="new">Styling by class.</p> </body> </html>
CSS
body { font-family: "Tahoma", serif; } h1 { color: #999999; } .completed { color: green; } .in-progress { color: orange; } .new { color: red; }

The code has changed, click "Update" or enable autorun.

You have moved to another page

Click inside the mini-browser to highlight this window.

100%
GoalsCompleted
0
    1. Add property text-decoration with the value line-through into the .completed rule,
    2. into the .in-progress rule add the padding-left property with a value of 15px,
    3. into the .new rule add background-color property with a value of #fff0f0.
    4. Mark the last two paragraphs of the outline as completed by replacing their class with completed.

    © 2023-2024, codehero.pro