Welcome to WebmasterWorld Guest from 50.19.0.90

Forum Moderators: incrediBILL

Message Too Old, No Replies

What Tag to Use for an ID

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

Full Member

10+ Year Member

joined:Feb 24, 2002
posts: 327
votes: 0


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)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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

Full Member

10+ Year Member

joined:Feb 24, 2002
posts: 327
votes: 0


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

Senior Member from US 

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

joined:Apr 9, 2011
posts:12692
votes: 243


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

Full Member

10+ Year Member

joined:Feb 24, 2002
posts: 327
votes: 0


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)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12692
votes: 243


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members