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

  • Home
  • SEARCH
  • 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 8996977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:49:35+00:00 2026-06-15T23:49:35+00:00

I have dynamically loaded a CSS file, and placed it inside a style tag

  • 0

I have dynamically loaded a CSS file, and placed it inside a style tag in a Windows 8 app.

Here’s how I load the CSS

function loadHeaders() {
    var monobookCSSURL = "http://lego.wikia.com/wiki/MediaWiki:Monobook.css?action=raw&ctype=text/css";

    WinJS.xhr({ url: monobookCSSURL }).then(loadCSS, xhrError);
}

function loadCSS(result) {
    var css = result.responseText;

    var style = document.createElement("style");
    style.innerText = css;

    document.getElementsByTagName("head")[0].appendChild(style);
}

When I use the DOM Explorer in Visual Studio to look at what is loaded, I see exactly what I expect, the final tag in the head being a style containing my CSS.

However, when I view my page, non of the CSS that is loaded comes into affect.

I tested this by adding another style tag manually into the HTML source, and that had effect, but the dynamic one didn’t.

How can I make this CSS have an effect?

Here is the style tag generated:


 #p-cactions ul li {
}
#p-cactions ul li a {
}
 #content {
}
 body {
    background: rgb(244, 248, 255);
}
 div.tleft {
    border: currentColor;
}
 div.tright {
    margin-left: 13px;
}
 .content-bg {
    background: white;
}
pre {
    overflow: auto;
}
.pBody {
    background-color: rgb(222, 227, 232);
}
body {
     background: #103A5A url(http://images2.wikia.nocookie.net/lego/images/f/f0/Studs-tile.png);
}
#p-personal li a {
     color: #DEE3E8;
}
.portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #355C70;  text-transform: Capitalize;
}
body[class*='ns-118'] {
}
body[class*='ns-119'] {
}
body[class*='ns-118'] #p-personal li a {
     color: #DEE8E3;
}
body[class*='ns-119'] #p-personal li a {
     color: #DEE8E3;
}
body[class*='ns-118'].portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #35705C;  text-transform: Capitalize;
}
body[class*='ns-119'].portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #35705C;  text-transform: Capitalize;
}
body[class*='ns-116'] {
}
body[class*='ns-117'] {
}
body[class*='ns-116'] #p-personal li a {
     color: #E8DEE3;
}
body[class*='ns-117'] #p-personal li a {
     color: #E8DEE3;
}
body[class*='ns-116'].portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #90152C;  text-transform: Capitalize;
}
body[class*='ns-117'].portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #90152C;  text-transform: Capitalize;
}
body[class*='Forum_Brickiforums'] {
}
body[class*='Forum_Brickiforums'] #p-personal li a {
     color: #E8DEE3;
}
body[class*='Forum_Brickiforums'].portlet h5 {
     color: #FFFFFF;  display: block;  height: 15px;  background-color: #B0B02C;  text-transform: Capitalize;
}
#title-rating2 {
     display: none;
}
#footer {
     background: #DEE3E8;  border-color: #355C70;
}
.wikiaOnly {
     display: none;
}
div.User-help-badge-1 {
    left: 500px; top: 2px; position: absolute;
}
div.User-help-badge-2 {
    left: 540px; top: 2px; position: absolute;
}
div.User-help-badge-3 {
    left: 580px; top: 2px; position: absolute;
}
div.User-help-badge-4 {
    left: 620px; top: 2px; position: absolute;
}
div.User-help-badge-5 {
    left: 660px; top: 2px; position: absolute;
}
.infoboxtoc .toc {
    margin: 0px; padding: 0px; border: currentColor; width: 100%;
}
.infoboxtoc #toctitle {
    display: none;
}
.infoboxtoc .NavHead {
    padding-right: 2px; padding-bottom: 12px; float: right;
}
.infoboxtoc .NavFrame {
    margin-bottom: -23px;
}
.ttbutton {
    border-radius: 2px; left: 114px; top: 200px; padding-right: 5px; padding-left: 5px; display: none; position: fixed; transform: rotate(90deg); background-color: rgb(173, 173, 173); -moz-transform: rotate(90deg); -webkit-transform: rotate(90deg); -o-transform: rotate(90deg);
}
.wikia-menu-button {
    display: none !important;
}
:first-of-type.portlet > .pBody > ul > li:not([id]) {
    display: none !important;
}

  • 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-06-15T23:49:36+00:00Added an answer on June 15, 2026 at 11:49 pm

    Instead of modifying the head tag, do it through the DOM api. This page should be helpful.

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

Sidebar

Related Questions

I have wrote a little function to dynamically include CSS file or JS file.
I have a few dynamically loaded images, with width and height being set inside
I'm trying to dynamically load css file using javascript, and for a moment i'we
So I have a light box that's dynamically loaded from a common.js file. (Legacy
I have a page that has fields dynamically loaded via JQuery. It allows a
I have a control bar on my application that has popovers with dynamically loaded
I have 3 category pages for a photography website that are loaded dynamically from
I have this code $(.delete2).click(function() { $('#load2').fadeIn(); } I have dynamically added item via
I have a app that requires a dll to be loaded at runtime and
I've got LESS/CSS file that is loaded on the client and the final CSS

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.