Jump to content

How to select root div that not have id or unic class?


Andrés González Tenorio

Recommended Posts

Suppose you have 4 nested div; that do not have a unique ID, because they are randomly generated and change from one user to another.

Now you should assume that only one or two of the innermost divs (3 and 4) can be identified because they have a class that does not change and is unique.

Something like what you see in the image that I have attached.

I need to make changes to div "1" that contains the rest but does not affect div "2".

How do I get there?

I've been trying several options but I can't.

I thank you if anyone could guide me.

It is not very important because I managed to solve it in another way, but I am left wondering how to do it if I have another similar situation.

Quote

<!DOCTYPE html>
<html>
<head>
<style>

.div3 { border: 2px red solid; }

.div4 { border: 2px pink solid; }

div {
    border: 1px solid blue;
    margin: 5px;

}


.div3::before, div {
    border: 3px green solid;
}


</style>
</head>
<body>

<div id="1"> 1
    <div id="2"> 2
        <div id="3" class="div3">
            3
        </div>
        <div id="4" class="div4">
            4
        </div>
    </div>
</div>

</body>
</html>

 

 

 

Screenshot_20221213_120122.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...