Introduction to <style>tag

The <style>tag in HTML is a powerful tool used for embedding CSS (Cascading Style Sheets) directly within an HTML document. It allows web developers to define the presentation style of HTML elements, such as colors, fonts, spacing, layout, and overall design. By using the <style>tag, developers can create a more visually appealing and user-friendly website.

Copy to clipboard
<!DOCTYPE html>
    <html lang="en">
    <head>
      <!-- Basic Meta Tags -->
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="description" content="A modern HTML document with attractive designs using advanced CSS within a style tag.">
      
      <!-- Title of the Page -->
      <title>title of <style> tag</title>
    
      <!-- Internal CSS using <style> tag for a Modern Design -->
      <style>
        /* General Styles */
        body {
          font-family: 'Roboto', sans-serif;
          background: linear-gradient(135deg, #f0f0f0, #ffffff);
          color: #333;
          margin: 0;
          padding: 0;
          line-height: 1.6;
          display: flex;
          flex-direction: column;
          min-height: 100vh;
    }
    
        /* Header Styling */
        header {
          background: linear-gradient(to right, #522bff, #4e2fff);
          color: white;
          padding: 40px 20px;
          text-align: center;
          box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
          border-bottom: 5px solid #0056b3;
    }
    
        header h1 {
          margin: 0;
          font-size: 3rem;
          font-weight: 700;
          letter-spacing: 1px;
          text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
          animation: fadeInDown 1s ease-out;
    }
    
        /* Main Content Styling */
        main {
          flex: 1;
          padding: 40px 20px;
          max-width: 900px;
          margin: 40px auto;
          background-color: #ffffff;
          border-radius: 12px;
          box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
          transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
        main:hover {
          transform: translateY(-5px);
          box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    }
    
        main p {
          font-size: 1.2rem;
          color: #555;
          margin-bottom: 20px;
    }
    
        .highlight {
          background-color: #ffe066;
          padding: 5px 10px;
          border-radius: 5px;
          color: #333;
          box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
          transition: background-color 0.3s ease, box-shadow 0.3s ease;
    }
    
        .highlight:hover {
          background-color: #ffd54f;
          box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }
    
        /* Footer Styling */
        footer {
          background-color: #333;
          color: #fff;
          text-align: center;
          padding: 20px;
          margin-top: auto;
          box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.1);
          border-top: 5px solid #222;
    }
    
        footer a {
          color: #aaa;
          margin: 0 10px;
          text-decoration: none;
          transition: color 0.3s ease;
    }
    
        footer a:hover {
          color: #fff;
    }
    
        /* Keyframes for Animations */
        @keyframes fadeInDown {
          0% {
            opacity: 0;
            transform: translateY(-20px);
    }
          100% {
            opacity: 1;
            transform: translateY(0);
    }
    }
    
        /* Responsive Design */
        @media (max-width: 768px) {
          header h1 {
            font-size: 2.5rem;
    }
    
          main {
            padding: 20px;
            margin: 20px;
    }
    
          main p {
            font-size: 1rem;
    }
    }
      </style>
    </head>
    <body>
    
      <!-- Header Section -->
      <header>
        <h1>Modern Styling Example :> LL</h1>
      </header>
    
      <!-- Main Content Section -->
      <main>
        <p>This is a paragraph demonstrating the use of the <span class="highlight">style</span> tag to add modern, attractive CSS to an HTML document.</p>
        <p>The <span class="highlight"><style></span> tag is useful for adding specific styles directly within the HTML, making quick design changes easy and effective.</p>
      </main>
    
      <!-- Footer Section -->
      <footer>
        <p>© 2024 Your Company Name. All rights reserved.</p>
        <nav>
          <a href="#">Privacy Policy</a> | <a href="#">Terms of Service</a> | <a href="#">Contact Us</a>
        </nav>
      </footer>
    
    </body>
    </html>

Global Attributes

AttributesDescription
accesskeySpecifies a shortcut key to activate or focus an element.
autocapitalizeControls whether and how text input is automatically capitalized.
classSpecifies one or more class names for the element, allowing CSS styling and JavaScript manipulation.
contenteditableSpecifies whether the content of an element is editable or not.
contextmenuSpecifies a context menu for the element.
dirDefines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto".
draggableSpecifies whether an element is draggable. Possible values are "true" or "false".
enterkeyhintSpecifies the action label or icon to be shown for the enter key on virtual keyboards.
hiddenIndicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set.
idSpecifies a unique identifier for the element.
inputmodeProvides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants.
isAllows you to specify the type of custom element.
langSpecifies the language of the element's content.
nonceA cryptographic nonce ("number used once") that can be used by Content Security Policy (CSP) to determine whether or not a given fetch will be allowed to proceed.
partSpecifies the element’s part in the shadow DOM.
slotAssigns a slot in a shadow DOM shadow tree.
spellcheckIndicates whether the element is subject to spell checking.
styleProvides inline CSS styling for the element.
tabindexSpecifies the tab order of the element.
titleAdds extra information about the element, displayed as a tooltip when hovering over the element.
translateSpecifies whether the content of the element should be translated. Possible values are "yes" or "no".
HTML AttributesGlobal AttributesEvent Attributes
To view the full list
To view the full list
To view the full list
elementsChrome BrowsersMicrosoft Edge BrowserFirefox BrowsersSafari BrowserOpera Browser
<style>YesYesYesYesYes