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 6839017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:40:04+00:00 2026-05-26T23:40:04+00:00

Is it possible to overwrite CSS file permanently using JavaScript / jQuery? I want

  • 0

Is it possible to overwrite CSS file permanently using JavaScript / jQuery?
I want to overwrite just 1 or 2 lines though.

Let’s say I have this CSS file:

div#box { width:100px; height:100px; }

then, if I apply this kind of JavaScript:

var sheet = document.createElement('style')
sheet.innerHTML = "div#box {width:200px;}";
document.body.appendChild(sheet);

the div only resized as long as the JavaScript is called (dynamically changed by JavaScript)

I want the CSS file would be overwritten like this

div#box {width:100px; height:100px; }
div#box {width:200px; } //CSS added

or more nicely,

div#box {width:200px; height:100px; } //CSS overwritten

What should I do?

Thx 😀

  • 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-26T23:40:05+00:00Added an answer on May 26, 2026 at 11:40 pm

    To elaborate on what has been said (And mmmshuddup and calchen are correct):

    Javascript alters files on the client side until the document is closed. The changes that scripts make are entirely temporary.

    However, javascript could technically use ajax to access a perl/ruby/php/python/whatever script hanging out on the server which would take arguments (What the class would be, which element it would be added to) and apply the classes permanently to your documents, or otherwise edit your style documents.

    Another solution would be creating and adding classes and then saving those classes as preferences for a user; you’d create a function which looked through an associative array of element id’s and their classes that need to be added upon the page being loaded. I suppose you’d use either cookies or preferably a database for this, if you have users at all. I’m just throwing hypotheticals out there.

    I’m pretty sure the server-side editing idea is your best option. It would probably be pretty safe to use regex to locate id’s and replace them with the new style.

    edit: Upon thinking about it, I realized your style finding and replacing function would have to be pretty sophisticated if you ever wanted to do replacements of styles that involved a lot of selectors. There is probably a more elegant solution, but it’s not coming to me. I think this would be a serious headache eventually.

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

Sidebar

Related Questions

Let's say we have a massive CSS file that is used to style the
Is it possible to overwrite the jquery mobile form button settings? I want to
Is it possible to overwrite the HTML property width of a table without using
I have a table with a background image using css property background-image. In table
Let's say I have the three html template files shown below. HTML is minimal
Is it possible to overwrite the eip in the following condition when I have
I'm trying to convert my jquery css to an external css file but had
I want to override the Tostring() method for changing some characters. Is it possible?
I have been working through the tutorial by Alex Young on using flash messages
Can somebody help me override the jquery UI css? I need to get something

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.