Forum Moderators: not2easy

Message Too Old, No Replies

Can A Class Be A Descendent Of Another Class?

         

Planet13

10:36 pm on Oct 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can a class be a descendent of another class?

.et_pb_section_video_bg .mejs-video { 
left:50%; position: absolute;
}


I thought that a class could be a descendent of an element such as a div or h1 or p tag, but not another class.

Thanks in advance for any illumination.

lucy24

2:25 am on Oct 21, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Anything can be a descendant of anything -- unless they're not allowed to be nested in the first place. No
p p

for example, with or without class names.

div.classname div.othername
div.classname div
div.classname .othername

div div.classname
div div
div .classname

.classname div.othername
.classname div
.classname .othername

et cetera. Or, for that matter,
div.inset div.inset

(two of the same name) if your structure warrants it.

You can go to multiple generations--
div.classname div div .othername ul li.thirdname ul table p.superspecial span.widget

But in real life (as opposed to, ahem, "themes" developed by teams of people who weren't speaking to each other) you rarely need to.

This applies both to classes and to IDs-- though it's pretty hard to think of a situation where you'd really need or want to spell out a style for
#idname #othername #thirdname

Planet13

12:53 pm on Oct 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you, Lucy!