Copy link to clipboard
Copied
Hi,
I apply a custom class to my ul tag so that the spacing is styled to my liking. Yes, I have to manually apply that to the tags.
The question is, how can I automate this formatting so that another person typing content and making a bulleted list would not need to touch the code to apply that class?
Is there a way? Is it via a small javaScript snippet? Appreciate the feedback.
Thank you!
Copy link to clipboard
Copied
I would change your class to include the container that the ul is inside of. Like .container ul or #container ul. Then apply the formatting to any ul in that div or outer container.
Copy link to clipboard
Copied
I agree with Ben. There's no reason to use an additional class if you don't need one.
The specificity of the container selector plus the ul and li tag should be all that's required to style the element. Anyone adding a bulleted list to that container should experience the same styles without having to insert additional class names.
Copy link to clipboard
Copied
If it is the case that all unordered lists in your site adhere to the same style rules, there is no need for the class. You can use the element (UL) as the selector.
If it is a case that all unordered lists in the same document need the same styling, then you can place the style rules in the <head> section of the page using UL as the selector. Again, no need for a class.
Copy link to clipboard
Copied
I have a feeling we are re-visiting this question from last month.