473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Don't understand text-align

So I've got one page where I have an image inside a DIV with
text-align: center and the
image is correctly centered in that block. Making me think that
text-align will center the contents of a block.

Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV
block with a fixed width which is smaller than the width of the
browser and that DIV block is in another DIV block that is the full
width of the browser.

What I don't understand is why text-align doesn't center the the first
DIV block inside the second.

I know I could bring these in via a left margin but I want everything
to be correctly centered based on the width of the browser.
Jul 20 '05 #1
7 3226
In article <24**************************@posting.google.com > in
comp.infosystems.www.authoring.stylesheets, Robert Nicholson wrote:
Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV
block with a fixed width which is smaller than the width of the
browser and that DIV block is in another DIV block that is the full
width of the browser.
I don't follow the above. Surely there is an easier way to do what
you're trying to do?
What I don't understand is why text-align doesn't center the the first
DIV block inside the second.


Anyway, a DIV by default is the full content width of its parent,
minus margin, borders, and padding of the inner DIV. An IMG, by
contrast, has an intrinsic width. That's probably at the root of
your problem, though as I say I don't understand your layout. (Hint:
post a URL with any query. A direct view is worth a thousand words
of description.)

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #2
ro****@elastica.com (Robert Nicholson) wrote in
news:24**************************@posting.google.c om:
So I've got one page where I have an image inside a DIV with
text-align: center and the
image is correctly centered in that block. Making me think that
text-align will center the contents of a block.
As its name implies, it will center the *text* within the block. Due to a
decision or two back in the early 1990s that seemed like a good idea at the
time but in retrospect seems to call to mind Douglas Adams' assertion about
the problem with ideas that sound good at parties being that such ideas
sound good *only* at parties, images are considered text for such purposes
(in HTML terms, an image is just a funny-looking character).
Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV
block with a fixed width which is smaller than the width of the
browser and that DIV block is in another DIV block that is the full
width of the browser.

What I don't understand is why text-align doesn't center the the first
DIV block inside the second.


Because a DIV block isn't a text element, it's a block. Blocks themselves
are, in conforming implementations, unaffected by the text-align property
(as you might guess, MSIE/Win prior to version 6 got this wrong, and IE6
will still do it if it's in quirks mode). To center a block, you really
do need to give it a width and then set its horizontal margins to auto.
The need to specify a width seems restrictive, but it's hard to imagine a
way to implement the margin calculations otherwise (since without an
explicit width, how do you determine how wide a block is? You can only do
it in a few special cases, like when there's a single line of text).
Jul 20 '05 #3
i have what I wanted working now and I understand the block vs incline
issues with text-align and margin: auto

However, during this I wasn't interested in whether or not there was a
way to wrap an image in a div and _correctly_ set the width of the div
to that of the image. Is there any way to do this? Supposing you
wanted to manipulate the something by putting it in a block it would
be nice to dynamically set the width of that block based on it's
contents.
Eric Bohlman <eb******@earthlink.net> wrote in message news:<Xn*******************************@130.133.1. 4>...
ro****@elastica.com (Robert Nicholson) wrote in
news:24**************************@posting.google.c om:
So I've got one page where I have an image inside a DIV with
text-align: center and the
image is correctly centered in that block. Making me think that
text-align will center the contents of a block.


As its name implies, it will center the *text* within the block. Due to a
decision or two back in the early 1990s that seemed like a good idea at the
time but in retrospect seems to call to mind Douglas Adams' assertion about
the problem with ideas that sound good at parties being that such ideas
sound good *only* at parties, images are considered text for such purposes
(in HTML terms, an image is just a funny-looking character).
Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV
block with a fixed width which is smaller than the width of the
browser and that DIV block is in another DIV block that is the full
width of the browser.

What I don't understand is why text-align doesn't center the the first
DIV block inside the second.


Because a DIV block isn't a text element, it's a block. Blocks themselves
are, in conforming implementations, unaffected by the text-align property
(as you might guess, MSIE/Win prior to version 6 got this wrong, and IE6
will still do it if it's in quirks mode). To center a block, you really
do need to give it a width and then set its horizontal margins to auto.
The need to specify a width seems restrictive, but it's hard to imagine a
way to implement the margin calculations otherwise (since without an
explicit width, how do you determine how wide a block is? You can only do
it in a few special cases, like when there's a single line of text).

Jul 20 '05 #4
I have what I wanted working however should you want to take a look
and critique it
feel free.

http://www.elastica.com/cgi-bin/show...me=weddingbell

One thing that I felt might be useful in the future was to be able to
wrap an image in a div
and manipulate the div. In doing this just exactly how can you set the
width of the div to
be that of the image plus a bit? I haven't seen anyways to dynamically
control the width
of div.

Stan Brown <th************@fastmail.fm> wrote in message news:<MP************************@news.odyssey.net> ...
In article <24**************************@posting.google.com > in
comp.infosystems.www.authoring.stylesheets, Robert Nicholson wrote:
Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV
block with a fixed width which is smaller than the width of the
browser and that DIV block is in another DIV block that is the full
width of the browser.


I don't follow the above. Surely there is an easier way to do what
you're trying to do?
What I don't understand is why text-align doesn't center the the first
DIV block inside the second.


Anyway, a DIV by default is the full content width of its parent,
minus margin, borders, and padding of the inner DIV. An IMG, by
contrast, has an intrinsic width. That's probably at the root of
your problem, though as I say I don't understand your layout. (Hint:
post a URL with any query. A direct view is worth a thousand words
of description.)

Jul 20 '05 #5
In article <24*************************@posting.google.com> in
comp.infosystems.www.authoring.stylesheets, Robert Nicholson wrote:
I have what I wanted working however should you want to take a look
and critique it


makes it harder to follow discussions.
before the material you're commenting on, it
When you put your comments

http://oakroadsystems.com/genl/unice.htm#upside

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #6
> Stan Brown <th************@fastmail.fm> wrote in message news:
(Hint:post a URL with any query. A direct view is worth a thousand wordsof description.)


I have what I wanted working however should you want to take a look
and critique it feel free.

http://www.elastica.com/cgi-bin/show...me=weddingbell

One thing that I felt might be useful in the future was to be able to
wrap an image in a div and manipulate the div. In doing this just
exactly how can you set the width of the div to be that of the image
plus a bit? I haven't seen anyway to dynamically control the width of
div.
Jul 20 '05 #7
Robert Nicholson wrote:

One thing that I felt might be useful in the future was to be able to
wrap an image in a div and manipulate the div. In doing this just
exactly how can you set the width of the div to be that of the image
plus a bit?
display: table-cell combined with padding will do the trick, but
afaik, only Opera does display: table-cell. More browsers (Mozilla,
possibly IE6/Win) will shrink a div if that div is floated and its
required width is less than the browser window.
I haven't seen anyway to dynamically control the width of div.


Bearing in mind the KISS principle, a database and server side
scripting language could suggest a width for certain elements.

--
Brian
follow the directions in my address to email me

Jul 20 '05 #8

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

Similar topics

40
by: komone | last post by:
"Now is the time for all good web developers to use stylesheets". Hmm OK, so I start this commercial site design with the express intent of using CSS entirely. (Something I haven't attempted in...
5
by: dlevy | last post by:
I posted an inquiry on how to create a database to calculate the cost of an assembly. pietlinden was kind enough to take the time to spell it out for me..... however, I can't understand the...
10
by: Wayne Wengert | last post by:
I am using a datareader (dr1) to read through rows returned from a query. I am getting the error: "No data exists for the row/column." at the "If IsDbNull..." in the code below. The field "Photo1"...
0
by: antonyliu2002 | last post by:
The full code is pasted below. It looks scarily long, but it's pretty simple. It is adapted from a sample code at MSDN. If you run it, and check it out from your browser, you'll see: ...
5
by: Larry | last post by:
I get a "Specified cast is not valid" when excuting the following line in the subroutine below: spParm = spAddImage.Parameters("@fnameIn").Value = ckfile.Text I'm not sure what I'm doing...
1
by: mgoold2002 | last post by:
Here is the offending excerpt from my code. I just began trying to port some vb code I'd written into my first .NET app. Public Class bannergenerator 'THIS IS AN ORDINARY WINDOWS FORM Inherits...
17
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post by:
Hello, I have build a website with approximately 30 html-pages. When I search this website in Google, I see the index.html or home.html on this website, but also other html-pages on this...
4
by: Dave | last post by:
When and what does .Net want to compile? I have a file called upload.cs. I made changes to it. Tried to rebuild. But it won't saying "the application is already precomiled." I would have...
7
by: sara | last post by:
I have a friend doing some pro-bono work for a non-profit that does job training for distressed kids under DCSS care. He asked me for code to do the following (he's using A2003). I can't find...
5
by: Thierry | last post by:
Hello fellow pythonists, I'm a relatively new python developer, and I try to adjust my understanding about "how things works" to python, but I have hit a block, that I cannot understand. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.