There is a much better alternative to both:
{width:auto;}
...on the child element.
For your example, with either {width:100%} or {width:300px}, if you decided to then apply padding or a border to the child (h1), then it will overflow outside its container. In you use pixel-width, then you would need to subtract the sum of (padding-left + padding-right + border-left + border-right) from the width of the child to get it to just fit inside, snug. In the case of percentage-width, you would have to do a squirely calculation to come up with the correct percentage (and probably still be a tad off).
But {width:auto} will automatically account for padding and border, and its computed width will be the appropriate amount less than the container, so that the outer edge of the border on H1 stays just within the content area of your div.