Code has been added to clipboard!

Add Unique Styles to Your Page Using Internal CSS

Reading time 2 min
Published Jun 11, 2019
Updated Oct 1, 2019

TL;DR — The internal CSS styling option is popular for applying properties to individual pages by wrapping all styles in the <style> element. Then, you place it in the <head> section of HTML documents.

Internal CSS: Main Tips

  • You can integrate internal CSS stylesheets by placing the <style> element in the <head> section of a page.
  • Internal styles apply to whole pages but not to multiple HTML documents.
  • Several pages can be styled by repeating the same block of internal styles in them.

How to Use Internal CSS

Internal CSS in HTML means adding CSS code in the <head> section of the document. Styling changes apply to every specific element found in the file.

Tip: this is a solid option for one-page websites or when you cannot create external stylesheets for your project.

Look at this example to see how to add the <style> element containing CSS rules for all the page:

Example
<head>
   <style>
      h1 {
         color: red;
         margin-left: 20px;
      }

      p {
         color: blue;
      }
   </style>
</head>

Internal styles are relevant to one page only. However, transferring the same <style> element to other pages is not an efficient practice for adding CSS to HTML documents.

Note: developers add styles in HTML by using internal stylesheets when they are creating templates for their clients or colleagues.

Internal CSS: Summary

  • By applying a style in HTML internally, you cannot reference this stylesheet with the <link> element.
  • Include CSS in HTML so it would be convenient to change and update content. Internal stylesheets can make website maintenance more challenging.
  • The best option is adding CSS to HTML externally. It means you create a .css file and link it to your website.
Tutorial
CSS3 Features
Syntax
Classes
ID Selectors
Attribute Selectors
Stylesheets
Inline
Internal
External
Box Model
Children Selectors
Pseudo Classes
Pseudo Elements
Variables
Counters
Text
Fonts
Web Fonts
Backgrounds
Background Images
Colors
Gradients
Opacity / Transparency
Shadow Effects
Transitions
Tooltip
Transform
Animations
Layout — Display
Layout — Position
Layout — Float
Layout — Clear
Layout — Horizontal & Vertical Align
Multiple Columns
Introduction
Responsive Web Design — Viewport
Responsive Web Design — Grid View
Responsive Web Design — Media Queries
Responsive Web Design — Flexbox Layout
Responsive Web Design — Images
Responsive Web Design — Videos
Borders
Margin
Padding
Width
Height
Outline
Links
Lists
Tables
Dropdown Menu
Navigation Bar
Images
Image Gallery
Border Images
Forms
Rounded Corners
Buttons
Box-Sizing
Selector Reference
Pagination Examples
Code Examples
CSS3 Browser Support Reference
Functions Reference
Speech Module Reference
Units
Web Safe Font Combinations
Cheat Sheet
:hover
@font-face
@keyframes
@media
align-content
align-items
align-self
all
animation
backface-visibility
background
background-clip
background-color
background-image
background-origin
background-position
background-size
border
border-image
border-radius
border-style
box-shadow
box-sizing
color
columns
filter
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-weight
hanging-punctuation
justify-content
line-height
margin
offset
opacity
order
outline
overflow
padding
perspective
position
resize
tab-size
text-align
text-decoration
text-emphasis
text-transform
text-shadow
transform
transition-property
translate
vertical-align
word-break
word-wrap
z-index