Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any way to determine the size of a printed string? 1

Status
Not open for further replies.

paket

Programmer
Jun 6, 2001
7
CA
Hello everyone.

I am coding a web-based front end to a database, and I would like to put a box behind the text labels to provide a background of contrasting colour. Of course, to do this I have to be able to find out the size of the text label in pixels so I can size and position the background box correctly. Is there any way to do this, or should I stick with specifying the font size in pixels?

thanks
 
Could you use css for this? Try something like:

<html>
<head>
<title>CSS Example</title>
<style type=&quot;text/css&quot;>
.label {
background-color: black;
color: white;
font-family: Verdana;
font-size: 10px;
padding: 1px 2px 1px 2px;
}
</style>
</head>
<body>
<span class=&quot;label&quot;>Heading 1</span>
</body>
</html>
 
I never thought of setting the background colour for a text label - I'm rather new to CSS. I will give it a try - thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top