473,626 Members | 3,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Center align a DIV without <center> tags

Is there a way to center the following div without using the <center>
tags?

<body bgcolor="#FFFFF F">
<center>
<div id="Test" style="backgrou nd-color:#000000; color:#ffffff; width:
80%; text-align:center; line-height:100px;"> Hello</div>
</center>
</body>

I want the div AND the text in the div to be aligned to the center.

Thanks...

(It's probably REALLY simple and I'll be quite embarassed that I
asked... but it's been one of "THOSE" days...)
Jun 27 '08 #1
4 2655
On Jun 18, 2:43*pm, DiamondEagle <and...@webmail .co.zawrote:
Is there a way to center the following div without using the <center>
tags?

<body bgcolor="#FFFFF F">
1. Use CSS not HTML attributes.
2. Set foreground and background colours together to avoid clashes
with user defaults.
<center>
<div id="Test" style="backgrou nd-color:#000000; color:#ffffff; width:
80%; text-align:center; line-height:100px;"> Hello</div>
</center>
</body>

I want the div AND the text in the div to be aligned to the center.
It's not 100% obvious and hence it is a FAQ. Set margin-left and
margin-right to auto.

Make sure that your doctype is triggering standards mode or IE won't
co-operate.

Steve

Jun 27 '08 #2
In article
<13************ *************** *******@34g2000 hsf.googlegroup s.com>,
DiamondEagle <an****@webmail .co.zawrote:
Is there a way to center the following div without using the <center>
tags?
The first two pages of

<http://netweaver.com.a u/centring/>

should give you a good idea of how to do both these things.

--
dorayme
Jun 27 '08 #3
dorayme scribed:
>In article
<13*********** *************** ********@34g200 0hsf.googlegrou ps.com>,
DiamondEagle <an****@webmail .co.zawrote:
>Is there a way to center the following div without using the <center>
tags?

The first two pages of

<http://netweaver.com.a u/centring/>

should give you a good idea of how to do both these things.
That seems like a very helpful site. Is there a navigation page? The home
page seems to have only a mail form.

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Jun 27 '08 #4
In article <ji************ *************** *****@4ax.com>,
Ed Jay <ed***@aes-intl.comwrote:
dorayme scribed:
In article
<13************ *************** *******@34g2000 hsf.googlegroup s.com>,
DiamondEagle <an****@webmail .co.zawrote:
Is there a way to center the following div without using the <center>
tags?
The first two pages of

<http://netweaver.com.a u/centring/>

should give you a good idea of how to do both these things.

That seems like a very helpful site. Is there a navigation page? The home
page seems to have only a mail form.
The things on this server are mainly just sets of self-contained pages.
This set seems short enough not to need a menu but if I grow it, I guess
I will put some navigation beyond the pages menu at top and bottom.

I am a bit worried at the slightly artificial connection of things under
the topic of centring in this set. What else should I put?

* My views on the aesthetics of centring?

* My take on why centring has such an appeal (I reckon it has to do
with the importance of left/right symmetry in animal evolution)?

* Perhaps an attempt at humorous, maybe even florid writing, about why
archery targets have the bull's eye in the centre; after all, even a
bull does not have its eye in the dead centre of its bulk, neither
mass-fully nor geometrically speaking? And besides, it has two eyes.

* Why don't dart boards have two bulls eyes like bulls, you could get
100 only if you can throw two darts at once each landing on different
eyes? Perhaps I could make and market a special and more rational
dart-board, closer to bull. (psst, Boji, wanna send me some $buckeroos
as an advance payment for one of these?)

--
dorayme
Jun 27 '08 #5

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

Similar topics

2
4701
by: The Plankmeister | last post by:
Hi... What's an equivalent of doing: <center>hello!</center> in 4.01 strict? I'm using stylesheets and am telling the various selectors I want to be centred to "text-align : center;" but they only align textual objects, not image objects:
5
2425
by: Nathan Sokalski | last post by:
As most of us probably know, the <centertag is deprecated. Because many elements and controls have an align attribute, centering them is easy enough. However, certain elements/controls do not (such as the ASP.NET Button and Label controls). For the ASP.NET label control I usually just add the following attributes: Width="100%" style="text-align:center;" However, this does not work for controls such as the ASP.NET Button control. The...
5
13475
by: Agix | last post by:
Hi there, Please check out : http://clarifysolutions.co.uk/certenroll/ The source is included below. This page is a test, so I can play about with paddings, margins and layouts using divs as semantically meaningless containers for bunch's of other elements - like everyone keeps telling me to make my code standards compliant. This request is not because I want a fix, but because I want to
1
3118
by: Steve Richter | last post by:
I am using <div align=centerto center a horizontal menu on the page. Problem is the center align of the div is rippling down to the menu items and causing the text of the dynamic popup sub menu items to be centered also. How can I center my navigation menu without centering the menu item text? thanks, -Steve
1
5160
by: jobs | last post by:
I have a simple login page with roughly a 300px x 300px image behind the asp.net login control. I need the login control to land in the middle of the image. I want both the image and the login controlrol to always be in the center of the page. How can I do this? I use position:absolute to get the asp.net login control on top of the image, but then when the IE window size is changed (by the user) the login control does not center. Here's...
3
4069
by: YaoBao | last post by:
In my main page, I use <cfinclude> tag to include my header and footer. But I get error. "Context validation error for the cfif tag. The start tag must have a matching end tag. An explicit end tag can be provided by adding </cfif>. If the body of the tag is empty, you can use the shortcut <cfif .../>. " If I put the three files into one big file without using <cfinclde> tag, the page display with no error. Here is my code: ...
13
3295
by: Stevo | last post by:
I've found that for IE6+, if you add the property text-align:center to a DIV, then *anything* inside it gets centered. That can be a table, an object/embed, another DIV, an image, or some text. Firefox and Safari on the other hand don't treat text-align in that way. In my tests on those browsers, they only centers images and text. Any DIVs, object/embeds or tables remain default unaligned and generally appear on the left. Considering...
5
4681
Plater
by: Plater | last post by:
To accomplish what I am looking for (the image centered in it's parent top 'centered') I have done this: <div id="backing"> <div id="lbImgBacker"> <center> <img id="Image1" src="banner.JPG" alt="" style="border-width:0px;" /> </center> </div> <div id="ExampleLeftAlignElement" ></div> <!-- other elements and the rest of the page -->
4
5277
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be horizonally and vertically centered within a <TD> </TD> area. No matter what I do the two image just present one above the other, albeit centered, NOT on top of each other. I originally did the entire page layout in TABLES until I found out I.E. 7...
0
8203
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8368
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
7203
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...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
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
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
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
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.