0

I am trying to add CSS for parent div but it is not working. Parent div is appending dynamic for class content. How to set padding for that div. If anyone knows please help to find the solution.

HTML:

<div> // how to set padding for this div
    <div class="content"> 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    </div>
</div>

CSS:

.content < div {
 
  padding:0px !important;

 }
EMahan K
  • 417
  • 1
  • 19
  • the combinator `<` doesn't exist. The only way to do something barely close is using [`:has`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has) but it's a very recent addition available on the browsers latest versions only (chrome mainly). If you look for css parent selector you may find interesting discussions also here on SO – Diego D Dec 20 '22 at 09:13
  • @DiegoD: Can you edit the css? – EMahan K Dec 20 '22 at 09:14
  • the problem is that if you want to use a css selector to style that parent using the current strategy, you only have 2 options: using `:has` and cutting off lots of people not having still a browser that supports it or use a piece of js that will check that condition adding a class to any element matching so that it will be styled with that class. `document.querySelectorAll('.content').forEach(contentEl => {contentEl.parentNode.classList.add('isparent');});` – Diego D Dec 20 '22 at 09:20

0 Answers0