This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > April 2006 > inline selectors? style="li {font-weight:bold;}" ?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author inline selectors? style="li {font-weight:bold;}" ?
Tobin Fricke

2006-04-25, 7:03 pm

In posting to a blog, I would like to bold every list item (<li> ).
Because I cannot influence the <head>...</head> section of the HTML
document, I can neither add a <style>...</style> block, nor reference an
external style sheet. Is there a way to accomplish this using the "style"
attribute and/or using div or span tags?

I want to do something like this:

<!-- desired application of css !-->
<div style="li {font-weight: bold;}">
...
<p>something</p>
<ul>
<li>foo</li>
<li>bar</li>
</ul>
</div>

I know that the following works, but it's useless, since if I were to do
it this way, I might as well use the <b> tag, and I get none of the
advantages of style sheets (namely, the ability to change the relevant
style in one place and have everything suddenly change appropriately):

<!-- useless application of css !-->
<ul>
<li style="font-weight: bold;">foo</li>
<li style="font-weight: bold;">bar</li>
</ul>

<!-- equivalent html - i thought we'd moved beyond this !-->
<ul>
<li><b>foo</b></li>
<li><b>bar</b></li>
</ul>

Also, what is the pertinent jargon in which this question is best and
most succinctly expressed?

thanks,
Tobin
--
Department of Physics, University of Rochester, Rochester NY 14627-0171
http://web.pas.rochester.edu/~tobin/



David Dorward

2006-04-25, 7:03 pm

Tobin Fricke wrote:

> In posting to a blog, I would like to bold every list item (<li> ).
> Because I cannot influence the <head>...</head> section of the HTML
> document, I can neither add a <style>...</style> block, nor reference an
> external style sheet. Is there a way to accomplish this using the "style"
> attribute and/or using div or span tags?


No. The closest you could get would be to use JavaScript to dynamically
alter the stylesheet (or loop through all the items and set inline style on
them).

This wouldn't be a very nice solution. You'd be better off getting the
ability to change the main stylesheet.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Andy Dingley

2006-04-25, 7:03 pm

On Tue, 25 Apr 2006 12:50:25 -0700, Tobin Fricke
<fricke@ocf.berkeley.edu> wrote:

>In posting to a blog, I would like to bold every list item (<li> ).
>Because I cannot influence the <head>...</head> section of the HTML
>document, I can neither add a <style>...</style> block,


Add a <style ... >...</style> element to the _<body>_ of the page.

It's bad and it's wrong, but it works (for quite useful levels of
"works"). It also allows you to use a:hover as a selector, which you
can't do with inline styles.
kchayka

2006-04-25, 10:57 pm

Tobin Fricke wrote:
> In posting to a blog, I would like to bold every list item (<li> ).
> Because I cannot influence the <head>...</head> section of the HTML
> document, I can neither add a <style>...</style> block, nor reference an
> external style sheet.


Sounds like you need a new blog. ;)

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Stephen Poley

2006-04-26, 3:50 am

On Tue, 25 Apr 2006 12:50:25 -0700, Tobin Fricke
<fricke@ocf.berkeley.edu> wrote:

>In posting to a blog, I would like to bold every list item (<li> ).
>Because I cannot influence the <head>...</head> section of the HTML
>document, I can neither add a <style>...</style> block,


It's not clear to me whether you are talking about your own blog or
someone else's. If you are posting to someone else's you are in any case
at the mercy of what they permit, and we can hardly offer any advice.
You should be happy to be able to do this:

><!-- equivalent html - i thought we'd moved beyond this !-->
><ul>
> <li><b>foo</b></li>
> <li><b>bar</b></li>
></ul>


If OTOH it's your own blog, you should get better software where you
*can* control the contents of the head section. There are enough open
source CMS's out there.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Toby Inkster

2006-04-29, 6:51 pm

Tobin Fricke wrote:

> <div style="li {font-weight: bold;}">


This is technically allowed, simply because the spec doesn't really
specify the exact syntax of the style attribute. The following draft
was published by the W3C:

http://www.w3.org/TR/css-style-attr

However, most browsers only support the syntax used in example 1.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews