correct use of <div>?
I have a client who is questioning my use of the div tag to apply classes to small areas of text such as : <div class="mystyle">text</div>
It works fine but they are implying that it's a bit of a hack - what is the correct usage of this tag? - can anyone tell me what the the div tag stands for and is it compliant/good practice to use it to apply text formatting to a single line of text?
Thanks for any comments.
<div> is a block level attribute like <p> for small inline class changes you should use <span>.
cheers sowen that would explain why you get an automatic line break after using div. I'll use span from now on which presumably doesn't give the line break.
you can also use class which becomes part of <P> also i.e. <P class=style>
You can apply a class to ANY HTML tag. As mentioned earlier, DIV is a block level element and as such implies a carriage return after the closing tag.
SPAN is the best tag to use to apply formatting to a single word or sentence.