amphibient
amphibient

Reputation: 31248

Same CSS style formatting differently based on pattern

Is it possible to define a style that assigns one set of formatting rules for non-parenthesized text and another for parenthesized? The reason for this is to avoid cluttering of format tags (like <b> or <span>). E.g if I have something like

<B>Item1</B> (expl), <B>Item2</B> (expl2), ..., <B>ItemN</B> (explN)

It would be cleaner to state it as

<span class="myClass">Item1 (expl), Item2 (expl2), ..., ItemN (explN)</span>

Where myClass is defined as formatting parenthesized text under a set of rules different from non-parenthesized (bolding non-parenthesized in this example).

Upvotes: 0

Views: 57

Answers (1)

Teja Kantamneni
Teja Kantamneni

Reputation: 17472

I don't think this can't be done in HTML/CSS but can be achieved by using Javascript. Once the page is loaded (onLoad), you can scan for items (may be using a regex) and then surround the text with custom tags.

Upvotes: 3

Related Questions