How to Add Internal Style Sheets (CSS) to a Web Page

f t g+ in

It is possible to change the style of a web page with the help of internal style sheets and we will demonstrate how to do that in this tutorial.

CSS (Cascaded Style Sheet) styles can be added to a web page as internal style sheet as well as an external style sheet. In general, it is good practice to keep all the styling in related external CSS files, e.g. style.css, but in some cases having internal styles may be preferred.

For example, if you want to style a single page and that styling will not be used on any other pages of your website, using internal style sheets makes more sense.

The following example shows how internal styles are added to a web page:

<!DOCTYPE html>
  <title>My Web Page</title>
  body { background-color: yellow }
  p { margin: 10px }

  <p>Page content...</p>

Please note that all the styling should be done within the opening and closing style tags.

Was this post helpful?

Please consider sharing it, and supporting us with a small tip. Thank you :)

f t g+ in