Previous task
Structure of HTML page5/10
Back to the list of tasks
  1. 1. Where HTML begins
  2. 2. The simplest HTML page
  3. 3. HTML page title
  4. 4. HTML page encoding
  5. 5. Connecting styles
  6. 6. Connecting external styles
  7. 7. The mystery of the CSS editor
  8. 8. Connecting scripts
  9. 9. Connecting external scripts
  10. 10. Connecting external styles and scripts again
Nest task
  • Courses
  • Sign up
  • Log in

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

  • Theory
  • Theory

Connecting styles

Styles can be written inside the HTML code of a page or they can be attached as an external file.

In the first case, styles are called "inline" styles, and they should be written inside the <style> tag. This tag is usually placed inside <head>. For example:

<head>
  <style>
    CSS code
  </style>
</head>

Inside <style> you write the usual CSS code.

Inline styles are used not so often, for example, to optimize page loading speed. More often external styles are used, which we will get acquainted with later.

  • index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Connecting styles</title> <!-- <style> h1 { font-size: 52px; font-family: "Monaco", "Courier", monospace; color: #618ad2; } </style> --> </head> <body> <h1>Connecting Styles</h1> <p>Connecting styles can be done in a number of ways.</p> <p>One of them is to write the styles inside the HTML page. This is done by using the &lt;style&gt; tag.</p> </body> </html>

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. Uncomment the <style> tag.

    © 2023-2024, codehero.pro