Code has been added to clipboard!

HTML style Tag

Reading time 2 min
Published Jun 29, 2017
Updated Sep 11, 2019

HTML style Tag: Main Tips

  • Used within <head> or <body>, HTML style tags define internal styling for elements.
  • This styling information contains CSS.
  • It might apply to the whole document or a part of it.
  • HTML inline styles override externally included CSS, but can be overridden by the style attribute.

Defining HTML Inline Style

HTML style tags define CSS styling information that applies to its content:

Example
<head>
<style>

/* This is internal styling */
h1 {
    color: indianred;
}

p {
    color: red;
}

</style>
</head>

You can place HTML style tags in <head> or <body> elements. We'd recommend choosing the first option, as that allows you to keep the content and styling information separate.

Note: you can also use <link> elements to apply styles kept in external stylesheets.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Common style Tag Attributes

There are two attributes you may use with HTML style tags. There is also one that is deprecated and should not be used when modifying style in HTML. However, you should get to know them all.

media is an optional attribute that defines which media should the styling properties affect. Its default value is all:

Example
<style media="screen">

type is an optional attribute describing the styling language as a MIME (Multipurpose Internet Mail Extensions) type. Its default value is text/css:

Example
<style type="text/css">

scoped was a boolean attribute, which set the scope for HTML inline style properties:

Example
<!-- a deprecated attribute -->
<style scoped>

Warning: the scoped attribute has been deprecated in HTML5 and should not be used for style in HTML.

Browser Support

Browser image
Chrome
1+
Browser image
Edge
All
Browser image
Firefox
1+
Browser image
IE
3+
Browser image
Opera
3.5+
Browser image
Safari
1+

Mobile Browser Support

Browser image
Chrome
18+
Browser image
Firefox
4+
Browser image
Opera
10.1+
Browser image
Safari
1+

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 22/01/2021
3176 People Used
Only 97 Left
Rating
5.0