2015-10-04 14:09


I'm interesting if there is a way to convert inline element styles to the css rules. The hardest part, I think, is to generate needed css-selectors. May be it's not possible at all, but may be there is a solution with js or php. Thank you.

For examle,

<div class="red" style="color: #red"></div>
<div style="color: #yellow"></div>
<div id="white" style="color: #white"></div>

will be converted, assuming classes and ids to

    div{color: #yellow}
    .red{color: #red}
    #white{color: #white}

<div class="red"></div>
<div id="white"></div>

I need this for my template generator, it preffered styles to be not inline, but in separate file or tag, so the original html code of blocks won't be changed, while editing colors, fonts, etc. I think, i explain clearly, cause english isn't my native language)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答