troubleshooting Question

Best practice - Using Utility Classes, Yes or No?

Avatar of SidFishes
SidFishesFlag for Canada asked on
CSS
1 Comment1 Solution116 ViewsLast Modified:
I'm trying to get away from years long habits of writing inline styles and move toward standalone stylesheets.

I'm wondering your thoughts on creating a utility class sheet (as well as sheets for specific purposes)

things like

.glow {
	color: white;
	text-shadow: black 0.1em 0.1em 0.2em;}
.indent-10{margin-left:10px;}
.indent-15{margin-left:15px;}
.margin-top-50{
	margin-top:50px}
.margin-top-75{
	margin-top:75px}

It seems to me to make sense especially when you can chain them

<div class="headline indent-15 glow">Some Text</div>

but does that follow best practice?

It does keep the page markup cleaner and does allow changes to the CSS without changing the page markup but something like this

.margin-top-75{
      margin-top:75px}

seems weird somehow.

I'll probably continue to do this in any case because it seems to work for me but I'm just wondering what others are doing.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros