GM addStyle: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m Text replace - "</pre>}}" to "</pre>" |
simplify |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
This | This method adds a string of CSS to the document. | ||
It creates a new <code><style></code> element, adds the given CSS to it, and inserts it into the <code><head></code>. | |||
Compatibility: [[Version_history#0.6.1|Greasemonkey 0.6.1+]] | |||
== Syntax == | == Syntax == | ||
{{Function|GM_addStyle|css}} | |||
=== Arguments === | |||
; <code>css</code> | |||
: <code>String</code> A string of CSS. | |||
=== | == Examples == | ||
<pre class='sample'> | <pre class='sample'> | ||
GM_addStyle("body { color: white; background-color: black } img { border: 0 }"); | GM_addStyle("body { color: white; background-color: black; } img { border: 0; }"); | ||
</pre> | </pre> | ||
== Notes == | |||
* Add <code>!important</code> at the end of a CSS declaration to override an existing value (i.e. values the page specifies). | |||
* Using [[Multi Line Strings]] may be helpful. | |||
Add <code>!important</code> at the end of | |||
[[Category:API_Reference|A]] | [[Category:API_Reference|A]] |
Revision as of 22:04, 8 February 2010
Description
This method adds a string of CSS to the document.
It creates a new <style>
element, adds the given CSS to it, and inserts it into the <head>
.
Compatibility: Greasemonkey 0.6.1+
Syntax
function GM_addStyle( css )
Arguments
css
String
A string of CSS.
Examples
GM_addStyle("body { color: white; background-color: black; } img { border: 0; }");
Notes
- Add
!important
at the end of a CSS declaration to override an existing value (i.e. values the page specifies). - Using Multi Line Strings may be helpful.