Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change style of no classed div?

I have this nested html

i want to access the second sibling, whose parent is div of class "x"

i tried using

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.x div:nth-child(2) {
  padding-bottom: 30px;
  margin-bottom: 30px;
}
<div class="x">
  <div>.....</div>
  <div> The One i want to change it's style</div>
</div>

The code works.

>Solution :

Its working, please see below. I have also added a child selector > . But without that also it should work.

.x > div:nth-child(2) {
  padding-bottom: 30px;
  margin-bottom: 30px;
  border: 1px solid red;
  color:red;
}
<div class="x">
  <div>.....</div>
  <div> The One i want to change it's style</div>
  <div>third div</div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading