473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple question about center alignment

MK
Hi,

I don't have much experience with Javascript and have a simple question.
Suppose one wants to write some text in the web page which needs to be
center aligned, then how to do it?

The command for writing some text is as follows if I am correct:

document.write( 'This is some text');

What needs to be done to write the above text with center alignment? Can
some one give me the syntax?

Thanks for your help.
MK
Jul 23 '05 #1
2 1673
DU
DKM wrote:

MK wrote:
Hi,

I don't have much experience with Javascript and have a simple question.
Suppose one wants to write some text in the web page which needs to be
center aligned, then how to do it?

The command for writing some text is as follows if I am correct:

document.writ e('This is some text');

What needs to be done to write the above text with center alignment? Can
some one give me the syntax?

Thanks for your help.
MK

You may want to output "<center>Th is is some text</center>"

D.K. Mishra


<center> is deprecated. Depending on what exactly MK wants to align (the
text node or the element holding the text), the CSS text-align property
or the CSS property margin-left and margin-right property should be used.

Using Web Standards in Your Web Pages
http://www.mozilla.org/docs/web-deve...her_Deprecated

CSS1: text-align: center
http://www.w3.org/TR/REC-CSS1#text-align
The text-align property specifies how text or inline elements are
aligned within an element.

CSS1: margin-left: auto; margin-right: auto; for block-level elements
http://www.w3.org/TR/REC-CSS1#horizontal-formatting
When both margin-left and margin-right are auto they are set to equal
values, thus centering a block-level element within its parent.
CSS1 horizontal formating
Worth mentioning is the excellent tutorial:
Centring using CSS by D. Dorward
http://dorward.me.uk/www/centre/

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Firefox 1.0.4 :)
Jul 23 '05 #2
DKM wrote:
You may want to output "<center>Th is is some text</center>"


Or, within a HTML document, '<center>This is some text<\/center>'.
PointedEars
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3257
by: Preston Crawford | last post by:
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know about hot scripts, etc. but I was wondering if any one could recommend one? Secondly, I also want to setup a journal. It's not really a "blog" although I guess blog software may work. But it isn't going to be a message board or anything like...
18
2452
by: Peter Smithson | last post by:
Hi, I've read this page - http://devrsrc1.external.hp.com/STK/impacts/i634.html but don't understand it. Here's the text - "Non-standard usage of setjmp() and longjmp() could result in compatibility problems. The contents of the jmp_buf buffer are specific
8
5115
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value types or std::vector<int>. So where I would use an int* and reallocate it from time to time in C, and randomly access it via , then I figure to copy the capacity and reserve methods, because I just need a growable array. I get to considering...
47
2659
by: sunglo | last post by:
Some time a go, in a discussion here in comp.lang.c, I learnt that it's better not to use a (sometype **) where a (void **) is expected (using a cast). Part of the discussion boiled down to the rule: if I cast a (sometype **) to a (void **) I am making a number of assumptions about the implementation's (void **) representation and length. Specifically, if I do the above cast I'm assuming that a (sometype **) and a (void **) have the same...
1
2294
by: Rabbit | last post by:
Dear All I'm new to use ASP.Net for developement, can someone tell me how can I create a web form with size say 300px x 300px, align vertically center on the page Because so far I can use Div to align it horizontally center on the page, but I still can't find out how to do the "Vertically-center alignment"! 'cause I really want such form/table can be located center in the web page.
1
1849
by: Jose | last post by:
Please como center a datagrid header and the data justify to right? Thanks a lot
13
3165
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall
7
1427
by: sxzong | last post by:
I have written a C program under unix, but some weird errors occurred: ==================================================== #include <stdio.h> typedef unsigned long ULONG; typedef unsigned short UWORD; typedef unsigned char UBYTE; typedef unsigned char BOOLEAN;
14
2434
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm specially having difficulties with center alignment of elements like images and tables. How is the "right" way to do it? (books that I have checked seemed to dodge the issue) I also have a doubt. html-atributes width and height are preferred over...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.