Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<h1> vs. <div style=""> 1

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have a <div> tag that needs to have a &quot;style=&quot; inserted. I want the style to match that created with an <h3> tag. What style parameters give me the equivalent font and size. TIA.
 
Why not just use an H3 with an ID? Other than that...

<style>
h3, #divID {font-size: 14px; color: limegreen;}
</style>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Doh! I guess because I didn't know I could put an id on an <h3>. Thanks.
 
For future reference (and ease) you can add an ID and a CLASS to just about any form element (html tag).

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
For future reference, why are some tags &quot;name=&quot; and others &quot;id=&quot;? To avoid the accusation of being consistant?
 
While some tags can have a name (like form tags), most tags can have an ID. You wouldn't name an <H3> but I just showed you why you might give it an ID. In the case of form tags, I usually give them the same name and ID.

The ID is used by the Document Object Model to identify individual page elements. You can capture it using the document.getElementById() javascript. You can also capture form elements using the document.formName.elementName code. Both load the same object into the variable.

Remember that you should not reuse IDs on a page - try to make each one unique...


BTW - if this is for that innerHTML post I answered before, another solution would have been to say

document.getElementById(&quot;usersname&quot;).innerHTML = &quot;<h3>&quot; + usersname + &quot;</h3>&quot;

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Thanks. Great explaination. If I understand, some tags can have both an 'id' and 'name'.

Indeed, this was related to the other question. So now I understand that one can put anything in the 'innerHTML' string (i.e. any valid HTML code). Cool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top