Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS – Is it possible to use a * to parse a class or id?

I’m adding some styles to some legacy code that dynamically adds a step counter per wizard step of this web app. For instance if the first page of the web wizard is completed the id attribute in the html would equal id="my-wizard-page-name.step1".

An example of what the html may look like in the inspector is below:

<div id="my-wizard-page.step1">
  <span>This is step 1</span>
</div>

After completing step 1 it would then reload and the div would be replaced with:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div id="my-wizard-page.step2">
   <span>This is step 2</span>
</div>

I am trying to add styles specific to the wizard page without updating the template class or id. Is it possible to parse the id in my css or less files. Im thinking something that would be similar to #my-wizard-page-name\.step* or #my-wizard-page-name* that would target every step within the page name.

(FYI: the backslah in the id is so I can use the . without the css assuming its a class on the id)

>Solution :

You can use attribute selectors

For your case, the starts with operator would be best: [id^=my-wizard-page]

Though, it’s probably better to just add a class like my-wizard-page-step to each item and use that to select them.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading