473,587 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

apply multiple styles

hi,

it is possible to apply multiple styles as shown in the following
example.

<STYLE TYPE="text/css"><!--

BODY { background-color:salmon; }
P { margin-left:20px; }
.clsCode { font-family:"Comic Sans MS"; font-size:10pt; color:navy;}
#idP1 { text-align:left; font-weight:bold; }

--></STYLE>

<P ID="idP1" CLASS="clsCode" >Multiple styles</P>

however, i would like to apply multiple styles in this manner with
scripting. i want to assign a style class and apply another along with
the previous one. how can i achieve this? what is the best approach for
IE 6? are there any w3c standards that makes applying multiple styles
possible?

is it possible to assign multiple selectors to class attribute?
<P CLASS="clsCode1 , clsCode2">Multi ple styles</P>

is it possible to nest selectors within them?

.clsCode1 { font-family:"Comic Sans MS"; font-size:10pt; }
.clsCode2 { clsCode1; color:navy;}

thanks.

Aug 4 '06 #1
3 2021
spolsky wrote:
<P CLASS="clsCode1 , clsCode2">Multi ple styles</P>
I don't know is it standard, but it works as the following:
<P CLASS="clsCode1 clsCode2">Multi ple styles</P>
is it possible to nest selectors within them?
.clsCode1 { font-family:"Comic Sans MS"; font-size:10pt; }
.clsCode2 { clsCode1; color:navy;}
I don't know there is any way to do so...

Aug 4 '06 #2
spolsky wrote:
hi,

it is possible to apply multiple styles as shown in the following
example.
Yes.

<STYLE TYPE="text/css"><!--
Do not use HTML comment delimiters inside style elements.

BODY { background-color:salmon; }
P { margin-left:20px; }
.clsCode { font-family:"Comic Sans MS"; font-size:10pt; color:navy;}
#idP1 { text-align:left; font-weight:bold; }

--></STYLE>

<P ID="idP1" CLASS="clsCode" >Multiple styles</P>

however, i would like to apply multiple styles in this manner with
scripting. i want to assign a style class and apply another along with
the previous one. how can i achieve this?
elementReferenc e.className = 'aClass';
elementReferenc e.className += ' anotherClass';

what is the best approach for IE 6?
The W3C standards compliant way - see above.

are there any w3c standards that makes applying multiple styles
possible?
Yes:

<URL: http://www.w3.org/TR/CSS21/ >
<URL: http://www.w3.org/TR/DOM-Level-2-Style/ >

is it possible to assign multiple selectors to class attribute?
<P CLASS="clsCode1 , clsCode2">Multi ple styles</P>
Yes, but lose the comma - class names are separated by spaces:

<P CLASS="clsCode1 clsCode2">Multi ple styles</P>

is it possible to nest selectors within them?

.clsCode1 { font-family:"Comic Sans MS"; font-size:10pt; }
.clsCode2 { clsCode1; color:navy;}
The rules for how selectors and rules cascade is contained in the spec
(see above). You really should ask such questions in a CSS news group:

news: comp.infosystem s.www.authoring.stylesheets
<URL:
http://groups.google.com.au/group/co...s?lnk=li&hl=en
>

--
Rob

Aug 4 '06 #3
hi,

RobG:
elementReferenc e.className = 'aClass';
elementReferenc e.className += ' anotherClass';
this is ok, but what if some other script already assigns its own
classes. in this case, it would be possible to track our classes in the
className attribute(by searching in the string) and remove or add them
accordingly but isn't there any flexible approach? it would be better
if className is a collection that we could determine easily if required
classes are applied or not.
or is there any better approach to apply our multiple classes without
depending on other scripts on the page?

Aug 5 '06 #4

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

Similar topics

5
5065
by: Jacob | last post by:
Hello, I would like to define some internal styles within an HTML page, but have those style overridden by an external style sheet if it exists at the location specified by a <link> element. If the external style sheet does not exist, then I would like the internal styles that are defined in the HEAD section of the HTML page to be used by default.
7
2353
by: Sandman | last post by:
I have a script that generates a hierarchical menu, but I am having problems assigning styles to each manu items different possible states. The possible states a menu item can be in is (and all of these can be combined unless they are mutually exclusive): 1. It can belong to a specific level in the hierarchy; 1, 2, 3 and so on. 2. It is the active menu 3. It is an inactive menu 4. It has children 5. It does not have children
4
5138
by: Carolyn Marenger | last post by:
Hey everyone, I am looking for your thoughts and opinions. Is it preferable to have one css file containing all the style information or break it up into multiple imported files for different types of formatting. For example, one file for page layout related items and another for text formattion? I have seen different combinations on different pages, and am wondering which people find is easier to maintain. Being from a coding...
5
10002
by: Don G | last post by:
Is it possible to link multiple stylesheets to a single web page? I have an overall stylesheet for my entire site, but there are a few pages with a minor differences. I originally had these as inline styles, but I would like to move them to external stylesheets, if possible. I did some Google searches, and I found links that seemed to suggest that multiple stylesheets could be linked to a single page, but didn't give the details as how...
6
4262
by: nboutelier | last post by:
Is it possible to apply multiple css styles to a textfield. Eg, if the value of the textfield is "foo bar" id like for 'foo' to be arial and 'bar' to be verdana. Or... id like for 'foo' to be underlined and 'bar' to be highlighted. Is this possible? -Nick
4
1372
by: Alan Silver | last post by:
Hello, I am displaying product details on a page and am allowing the site owner to specify the style in which the product details are displayed. I am debating which of two approaches to use here and would appreciate some comments. I intend to write a control that handles the actual display. This control would have a method that gets passed the product ID and the display style ID. It would pull the product details from a database and...
0
1148
by: dbuchanan | last post by:
How do I make multiple DataGridTableStyles serve the same table? (I can get multiple styles for the same datagrid, but not multple styles for the same *table* on the same datagrid) I want to do this because I want to have multiple views of the same table. I have a ComboBox where I select the view I want. There are ten views, but only three tables. I have no problem when I have a one for one relationship view=tablestyle as shown here;
0
1006
by: mumbaichef | last post by:
Hi, Can I apply style to datalist at runtime? The datalist control at runtime adds <tr>'s and <td>'s to the html and it messes up my desing. I was wondering if there is a way to apply styles to these <tr> and <td>. Thanks MumbaiChef
1
2319
by: Keoki12 | last post by:
I am a real newbie when it comes to HTML and CSS programming, so please be patient with me. I have a table. In one cell, I want 3 different styles for the text: First Line: Bold, Red Second line: Bold, Black Third line Black I used <span></span> and a class to allo 2 different styles of text in one cell, but I cannot figure out how to do 3 different styles.
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
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
8221
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
5395
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
3845
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1192
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.