Welcome to WebmasterWorld Guest from 50.16.47.14

Forum Moderators: incrediBILL

Message Too Old, No Replies

What Tag to Use for an ID

   
8:38 pm on Mar 5, 2012 (gmt 0)

10+ Year Member



I have a long line of text, and I want to ID just part of it so that I can change that part of the text with a function.

My code works fine:

<p class='Text'><var id='count'>ChangeThis</var>... more text I don't want to change

and I change ChangeThis with:

document.getElementById("count").innerHTML="NewText"

As I say the code works fine, but it's causing the text to be Italic. All the tags I have tried affect the appearance of the text.

It would be easy if I wanted to change all the text as I could simply put the ID in the <p>. But I only want to change some of the text inside the <p>.

What tag can I use to isolate the text I want to change? <var> makes it Italic.

Thank you, Peter
8:50 pm on Mar 5, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



<span>
...
</span>
9:01 pm on Mar 5, 2012 (gmt 0)

10+ Year Member



Great! Thanks.
3:18 am on Mar 6, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Or redefine var in your css.
4:46 am on Mar 6, 2012 (gmt 0)

10+ Year Member



lucy24,

I tried putting class='whatever' in the var tag and styling it with CSS that way. But it didn't work.

Or I guess I could have done an in-line style.

Anyway, span worked perfectly.

Thanks!
7:56 am on Mar 6, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



HTML used to be ugly and confusing. The mix of semantic and presentation types of tags and attributes wasn't all that logical.

If you now use CSS, the HTML part is so much easier. You need to know what goes in <head>, such as charset declaration, title, meta description, links to css files, links to js files, and what goes in <body>, such as headings, paragraphs, lists, tables, forms, clickable links, links to images, and how to use <div> and <span>. With those you have just about all the HTML you'll ever need.
9:14 am on Mar 6, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Did you say {font-style: normal} ? It isn't enough to add styles; you have to override the default. I do it often with <em>.

Incidentally, I think <var> is intended to be used for mathematical variables. That's why they're normally italicized. Not to text that you're planning on changing. There's no html tag for that, since the change isn't an html (or even css) action.