473,785 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to find Style Sheet Properties

I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;

Can anybody direct me to a list of CSS properties available in javascript?
Sep 4 '05 #1
9 2193
JimO wrote:
Can anybody direct me to a list of CSS properties available in javascript?


They are the same as those available in CSS, except that foo-bar becomes
fooBar.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 4 '05 #2
JimO wrote:
I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;

Can anybody direct me to a list of CSS properties available in javascript?


Here is the full list of CSS 2.1 style properties.

<http://www.w3.org/TR/CSS21/propidx.html>

There aren't any browsers that fully implement CSS 2 yet, so all
browsers will not support some properties, which ones aren't covered
will vary. CSS 1 is pretty well covered by the major browsers.

You can access the style in JavaScript by using 'camelCase', that is,
remove the hyphen and capitalise the following letter. e.g.
background-color becomes backgroundColor , etc.

<http://www.w3.org/TR/CSS21/propidx.html>
--
Rob
Sep 4 '05 #3


JimO wrote:
Can anybody direct me to a list of CSS properties available in javascript?


The W3C DOM Level 2 defines these properties:
<http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties>
So if you do DOM Level 2 scripting with JavaScript then those should be
supported. But browser implementations vary, in particular IE/Win is not
up to date so check
<http://msdn.microsoft. com/library/default.asp?url =/workshop/author/css/reference/attributes.asp>
as well where the CSS properties that IE/Win implements are listed, the
notation of that page is the CSS notation (e.g. border-style), to find
how to use that from script you have to follow the link for a certain
property then e.g. if you follow the link for float then you will find
<http://msdn.microsoft. com/library/default.asp?url =/workshop/author/dhtml/reference/properties/float.asp>
telling you that the CSS property is scripted as object.style.st yleFloat
for IE.
But the advice already given that CSS property-name becomes propertyName
for scripting is a valid one to start scripting if you already know the
CSS support of your target browser(s). If you run into trouble then with
a particular property name it is time to check those docs carefully.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 4 '05 #4

"RobG" <rg***@iinet.ne t.au> wrote in message
news:43******** *************** @per-qv1-newsreader-01.iinet.net.au ...
JimO wrote:
I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess
the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;

Can anybody direct me to a list of CSS properties available in
javascript?


Here is the full list of CSS 2.1 style properties.

<http://www.w3.org/TR/CSS21/propidx.html>

There aren't any browsers that fully implement CSS 2 yet, so all browsers
will not support some properties, which ones aren't covered will vary.
CSS 1 is pretty well covered by the major browsers.


If you want to see, exactly, the properties available (at least in IE or
Firefox - but it may work in others) you can use my debugging library here:

<http://www.depressedpr ess.com/depressedpress/Content/Development/JavaScript/Extensions/DP_Debug/Index.cfm>

Once added to the page it you can use:

Object.dpDump(B odyElement.styl e) to see all of the properties and their
current values.

Like Rob said however: for the most part all of the modern browser have
most, if not all, of CSS1 with CSS2 less likely and CSS3 even less likely.

For a more cross-browser approach to property availability you might also
consider checking out "TopStyle" from bradburysoftwar e.com - it's a truly
excellent style-sheet browser which can be set to display only those
properties available in specific specifications or browsers.

It also offers INSANELY useful style-checker which provides "quirk notes"
about different browser implementations and issues.

Very , very nice.

Jim Davis
Sep 4 '05 #5
Thanks for the input guys!
"JimO" <jo************ ********@earthl ink.net> wrote in message
news:Ny******** *********@newsr ead1.news.pas.e arthlink.net...
I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;

Can anybody direct me to a list of CSS properties available in javascript?

Sep 4 '05 #6
Jim Davis wrote:
[...]

If you want to see, exactly, the properties available (at least in IE or
Firefox - but it may work in others) you can use my debugging library here:

<http://www.depressedpr ess.com/depressedpress/Content/Development/JavaScript/Extensions/DP_Debug/Index.cfm>
That's neat, but it seems to never finish loading in Firefox, should
there be calls to close() after writing the frames (are frames necessary)?

Once added to the page it you can use:

Object.dpDump(B odyElement.styl e) to see all of the properties and their
current values.


A quick 'n dirty version is:

<div id="fred">fred div</div>
<script type="text/javascript">
function showAtts( el ){
var elStyle = el.style;
var txt = '';
for ( prop in elStyle ){
txt += prop + ': ' + elStyle[prop] + '<br>'
}
document.getEle mentById('fred' ).innerHTML = txt;
}
showAtts( document.getEle mentById('fred' ) );
</script>
[...]

--
Rob
Sep 4 '05 #7
JimO wrote:
I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;


Well, in my jsDHTMLlib.js library I have a function called
DCo2a(anyObject ) and it uses the for( x in anyObject) javascript
syntax to iterate through the members of an object , giving their names
and values. You'll find lots of good code to snag in there.
Just goto my site and click on [ DHTML ].
http://www.drclue.net

There is also code in there to read the entries directly from
stylesheets on-the-fly. DCgetCSSclass() . This latter function does not
yet work in Opera, but it does work for IE,NS,Firefox and most others.

I have a new piece of code I'm adding that allows one to access Opera
stylesheets too. I just need to incorporate it into the library.
This will allow all my DHTML applicaitons to configure their appearance
via CSS.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML/CSS,Javascript, TCP ...
--`
Sep 5 '05 #8
JimO wrote:
I'm a newbie at this and I can't seem to find a list properties names to
change styles on the fly. So far I've been lucky and managed to guess the
names such as

BodyElement.sty le.marginTop = 0;
BodyElement.sty le.paddingTop = 0;


Well, in my jsDHTMLlib.js library I have a function called
DCo2a(anyObject ) and it uses the for( x in anyObject) javascript
syntax to iterate through the members of an object , giving their names
and values. You'll find lots of good code to snag in there.
Just goto my site and click on [ DHTML ].
http://www.drclue.net

There is also code in there to read the entries directly from
stylesheets on-the-fly. DCgetCSSclass() . This latter function does not
yet work in Opera, but it does work for IE,NS,Firefox and most others.

I have a new piece of code I'm adding that allows one to access Opera
stylesheets too. I just need to incorporate it into the library.
This will allow all my DHTML applicaitons to configure their appearance
via CSS.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML/CSS,Javascript, TCP ...
--`
Sep 5 '05 #9

"RobG" <rg***@iinet.ne t.au> wrote in message
news:9f******** *********@news. optus.net.au...
Jim Davis wrote:
[...]

If you want to see, exactly, the properties available (at least in IE or
Firefox - but it may work in others) you can use my debugging library
here:

<http://www.depressedpr ess.com/depressedpress/Content/Development/JavaScript/Extensions/DP_Debug/Index.cfm>


That's neat, but it seems to never finish loading in Firefox, should there
be calls to close() after writing the frames (are frames necessary)?


Yeah... I noticed that... it DOES finish (on mine at least) but it just
taken upwards of 20 seconds. I'm not sure why (it does the same thing
seemingly regardless of the close()).

Frames are just to keep the controls visible - they're not needed for the
functionality. I could have done this in several other ways... but I
didn't. ;^)

I guess I can close the document now... I was doing straight
"document.write ()" so I wasn't closing (so that multiple dumps could go to
the same window... but I've since switched to accessing the DOM.

It'll be done in the next release.

Jim Davis
Sep 5 '05 #10

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

Similar topics

1
12184
by: David Bradbury | last post by:
I may be thinking about this the wrong way, but here goes: In my style sheet I've specified that bullet points should use a specific image rather than just be default bullet points. However, at some later point in the text I don't want to use the bullet point with an image, but rather use the standard bullet point. Is it possible to switch off a style sheet instruction for an individual instance? Or do I need to define a new style...
6
1446
by: Shawn Modersohn | last post by:
<script type="text/javascript"> var browser=navigator.appName if (browswer="Microsoft Internet Explorer") document.styleSheets.rules.style.left="50px" </script> IE does exactely what I hoped this script would do. Netscape says that document.styleSheets.rules has no properties. Since this script is targeted at IE anyway, should I be concerned? Also, is this script way oversimplified? All the css rule does is shift an image slightly to
5
1976
by: Andrew Poulos | last post by:
If I have an external stylesheet that is @imported into my page and it has an element that looks like this: * html td { font-style: italic; } how can I use javascript to change the font style to 'normal'? Andrew Poulos
2
3665
by: Kenneth P | last post by:
Hi, I'm developing asp.net (vb) apps in VS.NET 2003, and I'd like to know how you can write style sheet code in a sub in an .aspx page that when it's rendered as html/text/css code in the .aspx page. The idea is to programmatically write style sheet code that dynamically goes into every page and is rendered accordingly. Let's assume I wanted this kind of code into my rendered .aspx page
2
5706
by: mjansen.merge.emed | last post by:
Is there a way to override inline within the <bodya style of an element but not do it with a style attribute on the element? I know CSS Inheritance works for some styles, but doesn't appear to work for margins, etc. Here's my delimma: I'm generating HTML. I don't have access to the <head>. In the <head> is a stylesheet that defines a style for <p>. I have HTML I am wrapping around other generated HTML (that I don't have access to)...
8
41524
by: pamelafluente | last post by:
Hi guys, Is it possible to add "onload" (via Javascript) a new class to the <styleheader section? If yes, how would that be done ? <style type="text/css" media="screen"> .NewStyleClass{ whatever } </style>
10
2686
by: pamelafluente | last post by:
Hi, this time I am trying to add a style on the fly.I wish equivalency with this one (only the menuItemStyle line): <head> <style type="text/css" media="screen"> ... some static styles ... ..menuItemStyle{ background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px
4
3014
by: Duncan Jones | last post by:
I'm almost certain there is no easy answer to this question, but I'd thought I'd just check.... *Ignoring* for a second why I want to do this, is there any way to specify that an element in a page should ignore all CSS properties that have been defined for it, and to adopt some form of browser default? Suppose I want to add a <tdelement to an *arbitrary* web page. I want this element to ignore any CSS directives that may already apply
4
5635
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got around this problem I discovered that they're using Animations. I don't want to bloat my control with the Ajaxtoolkit's Animation stuff though. I guess I should tell you what the problem is. I have a TabStrip custom control. It's a Table that has...
1
10096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.