M
M
Mark Beldy2018-09-27 14:15:42
css
Mark Beldy, 2018-09-27 14:15:42

Tool to generate css selectors from html file?

Good afternoon, dear ones. There was an idea that it would be cool to automatically extract the values ​​of classes and id from the html file into css/sass/scss. A quick internet search didn't turn up any results. That's the question itself: is there a software / resource / script that allows you to pull out all the id and class values ​​\u200b\u200bof a tag from an html file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2018-09-27
@regress000

It is not difficult to do this, in fact, it is enough to use any HTML parser, there are many of them. Another thing is that the result will have to be parsed, filtering out what you really don’t need (and manually) and this process will almost certainly take more time than writing the selectors you need manually.
Also don't forget that:

  1. CSS selectors are far from just id and class name, they are much more flexible, and you don’t automate the most interesting options this way
  2. Modern IDEs, for example, the same JetBrains products are well able, understanding the context, to give a good autocomplete for CSS selectors according to the HTML structure, so your task has already been solved there, only much more efficiently

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question