Printing in one line like in Java or C/C++

J

Jamiil

JavaScipt
~~~~~~~
<script type="text/javascript">
name = new String("My Name");
document.write("<H4>Author: </H4>" + name);
</script>

I would like the word 'Author:' to be in 4th level heading and the name
variable value to be displayed in regular font, I get that but in two
lines. What can I do to get the browser to display the two values in
one line?


TIA.
 
T

Thomas 'PointedEars' Lahn

Jamiil said:
JavaScipt
What?

~~~~~~~
<script type="text/javascript">
name = new String("My Name");

You do not have to create a String object for this. A string value will do
just fine. Using `name' undeclared is overwriting the `name' property of
the global Window object in known HTML environments. Declaring `name'
perhaps disables it. Do not use `name' in global context.

var ref = "My Name";
document.write("<H4>Author: </H4>" + name);

Must be

document.write("<H4>Author: <\/H4>" + ref);

Should be

document.write( said:
</script>

I would like the word 'Author:' to be in 4th level heading and the name
variable value to be displayed in regular font, I get that but in two
lines. What can I do to get the browser to display the two values in
one line?

This has nothing to do with programming in an ECMAScript-conforming language
(which is on-topic here). Try CSS, and do not add whitespace at the end of
the element content:

<h4 style="display:inline">Author:</h4>

Never ever use a hX element if it is not a heading, just because it looks
nice on your browser! Use font-formatting instead.

<URL:http://www.w3.org/QA/Tips/headings>


PointedEars
 
H

Hal Rosser

Jamiil said:
JavaScipt
~~~~~~~
<script type="text/javascript">
name = new String("My Name");
document.write("<H4>Author: </H4>" + name);
</script>

I would like the word 'Author:' to be in 4th level heading and the name
variable value to be displayed in regular font, I get that but in two
lines. What can I do to get the browser to display the two values in
one line?

The h4 tag will show on its own line by default.
Why not use <p> and <span> tags with style attributes to get it to look the
way you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top