Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3634244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:45:18+00:00 2026-05-19T00:45:18+00:00

my use-case is the following : I’m composing an HTML page by using parts

  • 0

my use-case is the following :

I’m composing an HTML page by using parts that are valid HTML fragments but not valid pages,
like Divs; these elements are using CSS to manage their style.

I’d like to allow each fragment to be responsible for its own styling requirements and to not rely on the declarations of style-sheets in the main fragment (the one with the "HTML" tag).

So here come the question : is there any (standard) way to add some CSS styling outside the HEAD element (excluding the inline styling via the "style" attribute) ?

I guess I could use frames but I’d prefer to avoid this solution.

Thanks in advance for your help.

FINAL EDIT :

Thanks to the propositions of zzzzBov, JMC Creative and moontear, and after some testing, here is the answer :

  • use JavaScript to dynamically load some CSS style-sheets : HTML4/XHTML and HTML5 compliant,
  • embed "style" elements directly inside the fragments : non-compliant with HTML4/XHTML but seems to be broadly supported, and is HTML5 compliant.

As I must support email clients I’ve used the second solution which moreover is more simple.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:45:18+00:00Added an answer on May 19, 2026 at 12:45 am

    tl;dr:

    If you’re not comfortable using HTML features that haven’t reached a maturity level of W3C Recommendation, there isn’t a standard way of adding <style> to the <body> of a page.

    If you’re comfortable using less mature features, HTML5.2 appears to be standardizing <style> elements to be allowed anywhere flow content is expected (i.e. the <body> and most of its elements).

    If you’re already using the [scoped] attribute, stop using the [scoped] attribute, as it was never standardized and is losing browser support.

    History:

    HTML 4.01

    In HTML4.01 the style element was allowed in the <head> only. Browsers, being diligent about attempting to render what the author wants rather than what the author wrote have respected <style> elements in the <body> despite those pages technically being invalid.

    HTML 5

    The <style> element continued to be invalid in the <body>

    HTML 5.1

    In some working drafts of the HTML5.1 spec the <style> element was to allow for a [scoped] attribute, which would allow the <style> element to be used in flow content (i.e. in the <body>).

    As an example of how that could have been used would be:

    <!DOCTYPE html>
    <title>Example of using the scoped attribute</title>
    <div>
      <style scoped>
        p {
          color: darkred;
        }
      </style>
      <p>this text would be dark red</p>
    </div>
    <p>this text would be black</p>
    

    Support for the scoped feature was added to Firefox in version 21 and added in Chrome behind a flag in version 20. The feature didn’t receive enough support, so it was later removed from the HTML5.1 working draft.

    Chrome was first to remove the feature in version 36. Firefox has since set the feature to be behind a flag in version 55.

    HTML 5.2

    In the July 2017 working draft of the HTML5.2 spec, support was added for the <style> element to be allowed in flow content:

    Contexts in which this element can be used:

    • Where metadata content is expected.
    • In a <noscript> element that is a child of a <head> element.
    • In the body, where flow content is expected.

    Emphasis mine

    At the time of writing this addition has remained in the HTML5.2 spec, which is currently at the Candidate Recommendation maturity level.

    While this makes using <style> elements in the <body> still somewhat of a risk, this particular change is standardizing something that browsers have supported for many years.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following use case: There's a class called Template and with that
I have following use-case for marshalling a POJO to XML using Eclipselink MOXy 2.3:
Consider the following use case 1. User selects a product to purchase on seller's
I have the following use case , lot of code which was tightly coupled
I have the following use case, a struct with some boolean and int variables
I'm wondering how you'd implement the following use-case in REST. Is it even possible
Which checksum algorithm can you recommend in the following use case? I want to
The use case I can think of is the following: In a typical application,
Please consider the following simple use case: public class Foo { public virtual int
Question is should i use properties for my view controllers? Consider the following case:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.