CSS set width to parentNode's width

Is there a way in CSS to set the width of any element to equal the width of its parentNode? I tried 'inherit' - sounds logic - but it didn't work.

Thanks in advance.

Answers


width: 100%;

This means 100% of the parent element's width.

Note that it might not work if the element has the display property set to something different to "block", and in a few other cases.

If you try it on 2 nested divs, it'll work.


Depending on what element it is, setting the CSS property display: block will usually make it automatically fill all possible width, aka stretch to its maximum without overflowing on padding or borders.


Need Your Help

OpenNLP Name entity recognition model for time and date

nlp opennlp

I am using OpenNLP models for Name-entity recognition.