Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Replacing an align tag inside of <img using CSS

 
Thread Tools Search this Thread
Old 10-12-2004, 03:34 PM   #1
Default Replacing an align tag inside of <img using CSS


Hi,

Probably a dumb question, but I have a lot of align="left"s on my Happy
Tree Friends page.

i.e. lots of

<img class="image" src="/images/fluffy.png" width="90" height="90"
align="left" alt="Fluffy, the wobbly dragon" />

Is there a way I can say align="left" within CSS. I know there is a
text-align property, but not an image align. The stylesheet already has
a float:left (or float:right) within the image class structure.

Can it be done?

TTFN

Paul


Paul F. Johnson
  Reply With Quote
Old 10-12-2004, 03:35 PM   #2
Neal
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

On Tue, 12 Oct 2004 15:34:26 +0100, Paul F. Johnson
<> wrote:

> Hi,
>
> Probably a dumb question, but I have a lot of align="left"s on my Happy
> Tree Friends page.
>
> i.e. lots of
>
> <img class="image" src="/images/fluffy.png" width="90" height="90"
> align="left" alt="Fluffy, the wobbly dragon" />
>
> Is there a way I can say align="left" within CSS. I know there is a
> text-align property, but not an image align. The stylesheet already has
> a float:left (or float:right) within the image class structure.
>
> Can it be done?
>


text-align will work fine. It's actually misnamed, it ought to be
content-align.
  Reply With Quote
Old 10-12-2004, 03:57 PM   #3
Neal
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

On Tue, 12 Oct 2004 15:59:43 +0100, Spartanicus <> wrote:

> Neal <> wrote:
>
>> text-align will work fine. It's actually misnamed, it ought to be
>> content-align.

>
> Nah, confusion galore about it centering non inline stuff.


inline-align, anyone?
  Reply With Quote
Old 10-12-2004, 03:59 PM   #4
Spartanicus
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

Neal <> wrote:

>text-align will work fine. It's actually misnamed, it ought to be
>content-align.


Nah, confusion galore about it centering non inline stuff.

--
Spartanicus
  Reply With Quote
Old 10-12-2004, 04:04 PM   #5
brucie
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

In alt.html Neal said:

>>> text-align will work fine. It's actually misnamed, it ought to be
>>> content-align.


>> Nah, confusion galore about it centering non inline stuff.


> inline-align, anyone?


too hard to say when drunk. inlnaln just doesn't work.


--


v o i c e s
  Reply With Quote
Old 10-12-2004, 06:54 PM   #6
Jukka K. Korpela
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

Neal <> wrote:

>> Is there a way I can say align="left" within CSS. I know there is a
>> text-align property, but not an image align. The stylesheet already
>> has a float:left (or float:right) within the image class structure.
>>
>> Can it be done?

>
> text-align will work fine. It's actually misnamed, it ought to be
> content-align.


Will it? By definition, text-align applies to block elements only (hence
not to img elements unless you set the display property), and it affects
the alignment of each line.

Using the float property is the way to replace the align attribute,
should someone want to do that. (I would advice against rewriting working
code to clean it up, but suum cuique.) If this does not work for some
page, we need the URL for analysis.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


  Reply With Quote
Old 10-12-2004, 07:30 PM   #7
Spartanicus
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

"Jukka K. Korpela" <> wrote:

>By definition, text-align applies to block elements only (hence
>not to img elements unless you set the display property)


Wrong way 'round.

>Using the float property is the way to replace the align attribute,


Using float only to align is an ugly hack, sometimes a necessary evil
but not something that should be propagated as a generic method of
alignment.

--
Spartanicus
  Reply With Quote
Old 10-12-2004, 07:37 PM   #8
Spartanicus
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

Spartanicus <> wrote:

>"Jukka K. Korpela" <> wrote:
>
>>By definition, text-align applies to block elements only (hence
>>not to img elements unless you set the display property)

>
>Wrong way 'round.


Umm, on reflection I assume you meant to say that text-align can be
specified on block level elements only (I was thrown by the "not to img
elements" bit which makes no sense since the img element is empty).

--
Spartanicus
  Reply With Quote
Old 10-12-2004, 07:55 PM   #9
Jukka K. Korpela
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

Spartanicus <> wrote:

>>>By definition, text-align applies to block elements only (hence not
>>>to img elements unless you set the display property)

>>
>>Wrong way 'round.

>
> Umm, on reflection I assume you meant to say that text-align can be
> specified on block level elements only


No, I meant exactly what I wrote. You can _specify_ any property for any
element (e.g. img { text-align: left; ]), but by definition some
properties _apply_ (i.e., may have an observable effect on rendering) to
some elements only.

> (I was thrown by the "not to img
> elements" bit which makes no sense since the img element is empty).


It makes perfect sense. The img element is not a block element (unless
you explicitly set its display property). That's all that matters here.
But for the record: Emptyness is a matter of HTML syntax, not CSS. The
img element is (by default) a replaced inline element in CSS.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


  Reply With Quote
Old 10-12-2004, 10:01 PM   #10
Neal
 
Posts: n/a
Default Re: Replacing an align tag inside of <img using CSS

On Tue, 12 Oct 2004 18:55:00 +0000 (UTC), Jukka K. Korpela
<> wrote:

> Spartanicus <> wrote:
>
>>>> By definition, text-align applies to block elements only (hence not
>>>> to img elements unless you set the display property)
>>>
>>> Wrong way 'round.

>>
>> Umm, on reflection I assume you meant to say that text-align can be
>> specified on block level elements only

>
> No, I meant exactly what I wrote. You can _specify_ any property for any
> element (e.g. img { text-align: left; ]), but by definition some
> properties _apply_ (i.e., may have an observable effect on rendering) to
> some elements only.


You got me backwards. I wasn't suggesting we put text-align on the img
element, but on its container.

Agreed, though, that plenty of times float is better. But text-align
applied to an ancestor element will affect image positioning.
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump