ems are a measured based on the font-size and each of those elements have a different font size. The div is font-size: 16px and the textarea is font-size: 11px at least as a default in Chrome.
If you set the elements to the same font-size then they will be almost the same width. The remaining difference is because the textarea has padding and border too.
If you set the CSS to this, then the elements will be the same size:
div {
background-color: #eee;
width: 25em;
font-size: 16px;
box-sizing: border-box;
}
textarea {
width: 25em;
font-size: 16px;
box-sizing: border-box;
}
because they will both have the same font-size, and the widths will be based on the border-box instead of the content-box, so padding and borders will be included in the width.
References: