PDA

View Full Version : Defining character css property once


dhtmlhelp
05-01-2003, 09:18 PM
Hi,

I am trying to set the property of & n b s p ; once in the style sheet. Is this possible? How?

thanks,

DH

beetle
05-01-2003, 10:08 PM
I don't get it, you want to style all  s that are in your page?

Can't do it w/o some javascripting

dhtmlhelp
05-01-2003, 10:16 PM
Yes, I need it for all chracters defined by & ; (entire character set). i was hoping css had something to do it, I guess not.

DH

beetle
05-01-2003, 10:20 PM
Ya, you can't direclty appli CSS information to entites using selectors -- you'd have to search the HTML for them and apply a <span> with a given class

dhtmlhelp
05-01-2003, 10:35 PM
Hi Beetle,

that is what I am doing now, unfortunately I have many of these characters and was trying to find out if there was an alternative to the span option.

On another note I have another problem which I don't seem to be able to figure out. I have defined a text size of 0.8em. When I use the IE options and choose view>text size>smallest and view>text size>largest I somehow get a font size which is either much smaller or much bigger than many other sites I have compared.

Is there a way of setting a max largest and min smallest font without fixing the font size of course.

thanks,

DH

beetle
05-01-2003, 11:00 PM
I've run into that problem when I specify the base size in ems also. Instead, specify the base size as 'small' or 'medium' and use % or ems for everything else

About your &amp;nbsp;s<html>
<head>
<title>Insert a title you fool!</title>

<style type="text/css">
span.entity {
color: red;
text-decoration: underline;
}
</style>

<script type="text/javascript">

function styleEntities()
{
document.body.innerHTML = document.body.innerHTML.replace( /(\&amp;nbsp;)/g, '<span class="entity">$1</span>' );
}

</script>

</head>

<body onload="styleEntities()">

<div>
Just &amp;nbsp; some &amp;nbsp; entities &amp;nbsp;
</div>

</body>
</html>

brothercake
05-01-2003, 11:52 PM
Originally posted by beetle
I've run into that problem when I specify the base size in ems also. Instead, specify the base size as 'small' or 'medium' and use % or ems for everything else
Interesting .. I hadn't really considered that a problem; I did wonder though. Ta :)

liorean
05-02-2003, 12:22 AM
Only one problem - it's not attribute safe. You can't go have <a href="http://example.net/?id=n.n.<span class="entity">&amp;amp;</span>name=john%20doe"> in the html, can you?

This could be solved by using a full tree traversal with checks for node type. Entities are 5, entity references are 6.

dhtmlhelp
05-02-2003, 01:54 AM
Hi Beetle,

thanks. I was using small but mozilla and IE interpret them in different ways. For example x-small in IE is equivalent to small in Mozilla, and small in IE is equivalent to medium in Mozilla.

How can I get around both problems? Should I use a div for the whole document where font size is defined as, say, small, and every element inside the main div as em?

thanks for all the feedback,

DH

beetle
05-02-2003, 05:47 AM
Oh, use an XHTML doctype and IE will behave

beetle
05-02-2003, 05:26 PM
Okay, how you have your text-size defined via CSS is way different from how i'd do it

html, body {
margin: 0;
padding: 0;
font: small Verdana, Arial, sans-serif;
}Now, that defined the base size against which all other relative sizes will be, erm, sized. So, 50% or .5em will be half. 200% or 2em will be double. Just make sure to pay attention to your nesting, because relative font sizes go off of the font-size of the parent element's font-size.