Previous task
Introduction to HTML and CSS9/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

Other ways to connect CSS

Setting the styles of each tag using the style attribute is very inconvenient. It also leads to clogging HTML code with repetitive pieces of CSS.

Fortunately, there are other ways to connect styles. The first is to connect an external file using the <link> tag, and the second is to use a special <style> tag.

Now you will get acquainted with the second section of the editor - the style.css tab. The code from the CSS editor is inserted into the HTML document as if you had written it in the <style> tag. This is how this tab looks like:

index.htmlstyle.css

First, we'll clean up the code in the HTML editor, and then we'll start step-by-step styling our outline using other CSS features.

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html> <head> <title>Other ways to connect CSS</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Course outline</h1> <p style="color: green;">Paired tags.</p> <p style="color: green;">Single tags.</p> <p style="color: green;">Tag attributes.</p> <p style="color: green;">Inline styles.</p> <p style="color: red;">External Styles.</p> <p style="color: red;">Styling by class.</p> </body> </html>
CSS
/* body { font-family: "Tahoma", serif; } p { color: green; } */

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. Remove all style attributes from paragraphs,
    2. then remove the /* characters in the first line of the CSS editor.

    © 2023-2024, codehero.pro