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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:53:27+00:00 2026-06-01T21:53:27+00:00

I will be specific: How do I replace <style type=text/css> .class1 {font-weight:bold; font-size:10pt;} .class2

  • 0

I will be specific:

How do I replace

<style type="text/css">
   .class1 {font-weight:bold; font-size:10pt;}
   .class2 {font-weight:bold; font-size:12pt;}
   ...
   .classN {font-weight:bold; font-size:8pt; vertical-align:sub;}
</style>

<div class="class2" style="color:blue;">
   Bold Text
</div>

With this:

<div style="color:blue; font-weight:bold; font-size:12pt;">
   Bold Text
</div>

**Note that
– node could be any node
– attributes order doesn’t care.
– class attribute don’t need to be stripped

There is any HTML method (C#) to do that? Regex? Any ideas?

Thanks in advance!

  • 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-01T21:53:30+00:00Added an answer on June 1, 2026 at 9:53 pm

    If you are using jquery, you can use this plugin:

    /*
     * getStyleObject Plugin for jQuery JavaScript Library
     * From: http://upshots.org/?p=112
     *
     * Copyright: Unknown, see source link
     * Plugin version by Dakota Schneider (http://hackthetruth.org)
     */
    
    (function($){
        $.fn.getStyleObject = function(){
            var dom = this.get(0);
            var style;
            var returns = {};
            if(window.getComputedStyle){
                var camelize = function(a,b){
                    return b.toUpperCase();
                }
                style = window.getComputedStyle(dom, null);
                for(var i=0;i<style.length;i++){
                    var prop = style[i];
                    var camel = prop.replace(/\-([a-z])/g, camelize);
                    var val = style.getPropertyValue(prop);
                    returns[camel] = val;
                }
                return returns;
            }
            if(dom.currentStyle){
                style = dom.currentStyle;
                for(var prop in style){
                    returns[prop] = style[prop];
                }
                return returns;
            }
            return this.css();
        }
    })(jQuery);
    

    and try something like this

    <div class="class2" style="color:blue;">
       Bold Text
    </div>
    <script type="text/javascript">
      var computedStyle;
      $("div[class^='class']").each(function(){
        computedStyle = $(this).getStyleObject();
        $(this).css(computedStyle);
        $(this).attr('class','');
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that the tasks in a specific sprint will not divide perfectly into the
I am trying to put together a query that will display one specific record
I will try to be specific if I can - please be patient, first
This is a very specific question which will probably earn me the tumbleweed badge,
Which will perform better when searching for a key with a specific prefix in
I need a specific user who will be only used for reporting. That user
I like to create a specific filename for a file that will be created
I'm writing a program which will allow to load a specific managed .DLL file
I'm creating an application that will store geolocation data for specific transactions. Should I
i have this code that will check the array contains the specific string and

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.