CSS Subclasses? Multiple Classes?

Here’s the CSS code:


.box {
				height:100px;
				position:relative;
			}
			
.box1 {
				background:red;
				top:-10px;
				left:-10px;

and the HTML code:

<div class="box box1"></div>

What do you call the two CSS classes in the div above??? (“box box1” with the space in between)

I’ve tried searching for CSS subclaseses with very little luck.
It seems to work in my Chrome and IE. Not sure if it’s safe to use across other/older browsers.

Thanks

I don’t call it anything, it’s just applying two different classes to one element.
Neither is a “sub class”, that would infer that there existed some hierarchy or relationship between the two classes.

I would not worry about it, it is quite common practice to do this.
Some frameworks add several classes to a single element, though it’s not something I approve of (it smells of in-line styling in disguse).
Though there is nothing wrong with having two, maybe occasionally three classes IMO.
Opinions may vary. :shifty:

2 Likes

it smells of in-line styling in disguse

lol, okay.

Two would be fine. that’s what I was wondering about. Thanks

Yeah, I’m talking about:-

<div class="box1 red pos-relative float-left align-center width-50 bord-black">

Or the kind of rubbish you in Bloatstrap.

Something like:-

<div class="MyFancyContainer clearfix">

…is quite sensible and normal.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.