[TW5] Image widget: understanding the width/height attribute

207 views
Skip to first unread message

Michael

unread,
Oct 17, 2014, 9:22:29 AM10/17/14
to tiddl...@googlegroups.com
I am trying to understand how image sizing works when using the image widget:

The width and height attributes in the TW image widget is are given as bare numbers, without any absolute or relative length dimensions like pt or %. Adding pt, %, etc. has no effect.

<$image source="..." width=300 />

In CSS the width/height attribute requires an absolute or relative length dimension.

Does that mean that even if I assign a class within the image widget, I cannot affect image size and width via custom CSS, but only directly in the widget?

Cheers,
Michael

Jeremy Ruston

unread,
Oct 19, 2014, 8:23:06 AM10/19/14
to TiddlyWiki
Hi Michael

The width and height attributes in the TW image widget is are given as bare numbers, without any absolute or relative length dimensions like pt or %. Adding pt, %, etc. has no effect.

That's correct. The suffix "px" is added to the provided value before use. HTML5 only allows pixel values for img width and height:


In practice, browsers still support the HTML4 option of percentage values (which are taken as a percentage of the containing element). I've made a change for 5.0.13 so that percentage values can also be specified:

 
<$image source="..." width=300 />

In CSS the width/height attribute requires an absolute or relative length dimension.

Does that mean that even if I assign a class within the image widget, I cannot affect image size and width via custom CSS, but only directly in the widget?

You can give the image a class and resize it in a stylesheet without any limitations. If no width and height are provided to the image widget the generated img tag will take its size from the browser CSS rules in the usual way.

Best wishes

Jeremy

 

Cheers,
Michael

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Reply all
Reply to author
Forward
0 new messages