470,647 Members | 1,230 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

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

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/

Apr 25 '06 #1
5 5323
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
Apr 25 '06 #2
On Tue, 25 Apr 2006 12:50:25 -0700, Tobin Fricke
<fr****@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.
Apr 25 '06 #3
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.
Apr 26 '06 #4
On Tue, 25 Apr 2006 12:50:25 -0700, Tobin Fricke
<fr****@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/
Apr 26 '06 #5
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

Apr 29 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

32 posts views Thread by Will Hartung | last post: by
5 posts views Thread by Tmuld | last post: by
37 posts views Thread by Jan Wagner | last post: by
reply views Thread by Altemir | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.