homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
What Tag to Use for an ID
peterinwa

10+ Year Member



 
Msg#: 4425230 posted 8:38 pm on Mar 5, 2012 (gmt 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

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4425230 posted 8:50 pm on Mar 5, 2012 (gmt 0)

<span> ... </span>
peterinwa

10+ Year Member



 
Msg#: 4425230 posted 9:01 pm on Mar 5, 2012 (gmt 0)

Great! Thanks.

lucy24

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



 
Msg#: 4425230 posted 3:18 am on Mar 6, 2012 (gmt 0)

Or redefine var in your css.

peterinwa

10+ Year Member



 
Msg#: 4425230 posted 4:46 am on Mar 6, 2012 (gmt 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!

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4425230 posted 7:56 am on Mar 6, 2012 (gmt 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.

lucy24

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



 
Msg#: 4425230 posted 9:14 am on Mar 6, 2012 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved