Hola:
Solo se me ocurre con javascript
:
Código:
<html>
<head>
<title>1, 2, 3, ¡probando!...</title>
<script>
function ajuste(texto) {
var tempSpan = document.createElement("span")
tempSpan.appendChild(document.createTextNode(texto));
document.body.appendChild(tempSpan);
ancho = tempSpan.offsetWidth;
document.body.removeChild(tempSpan);
return ancho;
}
</script>
</head>
<body onload="x = document.getElementById('prueba'); x.style.width = ajuste(x.value) + 'px'">
<input type="text" id="prueba" value="texto" />
</body>
</html>
Bueno, es preferible poner unos pocos pixeles más... además, el ejemplo es con un input
Saludos