How to add 'style="width:100px"' in Global Custom Text field in a view? It seems that the Global Custom Text field in a view delete part of my text.

I write this:

&lt;div class="my-class" style="width:100px"&gt;Hello&lt;/div&gt;


but get this:

&lt;div class="my-class"&gt;Hello&lt;/div&gt;


The text removed is this

style="width:100px"


I need to be able to include it.

The value of the 'width' is provided by a token ([field_width]), that's why I need to add it here. It is dynamic value.

Update: I just see that this is a security measure, then how can I make View accept this using a function?
Here is a fun and a little naughty solution to this:

1.) Instead of style, set the token as value="[token]" - make sure your token is only a number, no alphabetic characters like px etc.

--- Value is set and DIV is spat out ---

&lt;div class="my-div" value="100"&gt;&lt;/div&gt;


2.) Use jQuery to get the value of value="" - define it and use it when the page loads:

$(document).ready(function(){ 
var div_width = $('.my-div').val();
$('.my-div').width(div_width);
});


The width will now be appended to the div via inline-style using jQuery. Not optimal, not recommended but it should work.

More on adding custom jQuery to your Drupal installation: https://www.drupal.org/node/171213