Computer >> Computer tutorials >  >> Programming >> HTML

How to use inline CSS (Style Sheet) in HTML?


To add inline CSS in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with CSS properties such as font-family, font-style, text-decoration, direction, etc.

Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.

How to use inline CSS (Style Sheet) in HTML?

Example

You can try the following code to use inline CSS in HTML. Here, we are adding font size to heading using inline CSS

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Inline CSS</title>
   </head>

   <body>
      <h1 style=”font-size: 20px;”>
         Tutorials
      </h1>
      <p>We have tutorials on Programming, CMS, Scripting Languages, etc.</p>
   </body>
</html>