0

I have this HTML code:

<body>
<table width="650">
<tr width="650">
<td width="650">
lots of text here
</td>
</tr>
</table>
</body>

How can I use a variable/constant to represent 650? Do I need to use javascript or something?

What I really want is a way to reuse some code so that I only need to change the width value in one place.

Nb. I'm not using a database or anything. Just a simple html page, so I'd like to do something like: int x = 650

2
  • Where would the value of the variable come from? Can you use server-side scripting for it, like PHP? Commented Feb 25, 2014 at 0:39
  • Hi Barmar, please see my edit. Commented Feb 25, 2014 at 1:17

2 Answers 2

4

Using css:

table,tr,td{width:650px;}
Sign up to request clarification or add additional context in comments.

Comments

1

CSS

table, tr, td {
    width: 650px;
}

HTML

<body>
<table>
    <tr>
        <td>
            lots of text here
        </td>
    </tr>
</table>
</body>

2 Comments

I do not think this is an answer to the question, as they are asking how to use a variable for the width of the table/tr.
See the edit to the question, he just wants a way that he can change the value in one place. This solves that problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.