Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ what is the difference between div tag and span tag ??

Posted by: deb1 Jun 11 2020, 09:16 AM

please can someone tell me what is the difference between div tag and span tag ??

Posted by: Christian J Jun 11 2020, 10:02 AM

Please start new threads instead of posting in old ones.

(This post was originally posted in https://forums.htmlhelp.com/index.php?showtopic=293 )

Posted by: deb1 Jun 11 2020, 10:46 AM

QUOTE(LetsLearnCodingTogether24 @ Jun 11 2020, 10:26 AM) *

for anyone still having problems like these, I can personally vouch for a course I took on Udemy.

It's https://www.udemy.com/course/html-css-and-javascript-the-complete-web-developer-course/


is it free or do we have to pay for the course?

Posted by: deb1 Jun 11 2020, 12:10 PM

what is the difference between div and span tags in html?

Posted by: pandy Jun 11 2020, 01:50 PM

One is block level and one is inline.

https://htmlhelp.com/reference/html40/block.html


Posted by: deb1 Jun 11 2020, 02:26 PM

QUOTE(pandy @ Jun 11 2020, 01:50 PM) *

One is block level and one is inline.

https://htmlhelp.com/reference/html40/block.html


Can you please write a html coding for me on here where it shows how to use span and div tag in it. it will be easier for me to understand that way smile.gif

Posted by: pandy Jun 11 2020, 02:43 PM

We already talked about this. Use DIV to group things together or when no other block level element fits.

SPAN is similar to DIV in that it lacks features in itself, but it's inline (text level). If you want a word to stand out because it's important, you'd probably use EM and style it to your heart's content.

CODE
This is <em>important</em>.


But if you want to make all words have different colors because you think it looks pretty (just a dumb example), you don't want to use a meaningful element, but you still need something to apply CSS to, so SPAN is your choice.

CODE
<span>Nothing</span> <span>here</span> <span>is</span> <span>of</span> <span>importance</span>.


In the first example important will stand out even without CSS. The browser may make it bold or italic. In the second example all the words will look the same without CSS. SPAN doesn't carry any meaning.

Posted by: deb1 Jun 11 2020, 02:54 PM

QUOTE(pandy @ Jun 11 2020, 02:43 PM) *

We already talked about this. Use DIV to group things together or when no other block level element fits.

SPAN is similar to DIV in that it lacks features in itself, but it's inline (text level). If you want a word to stand out because it's important, you'd probably use EM and style it to your heart's content.

CODE
This is <em>important</em>.


But if you want to make all words have different colors because you think it looks pretty (just a dumb example), you don't want to use a meaningful element, but you still need something to apply CSS to, so SPAN is your choice.

CODE
<span>Nothing</span> <span>here</span> <span>is</span> <span>of</span> <span>importance</span>.


In the first example important will stand out even without CSS. The browser may make it bold or italic. In the second example all the words will look the same without CSS. SPAN doesn't carry any meaning.
\


OK understand it now . thank you again for explaining it to me.

Posted by: deb1 Jun 11 2020, 02:58 PM

Just wondering is BOOTSTRAP a part of html also ? what is the difference between html and bootstrap?

Posted by: pandy Jun 11 2020, 03:52 PM

You already asked that and I answered it here.
https://forums.htmlhelp.com/index.php?s=&showtopic=60300&view=findpost&p=139399

Posted by: deb1 Jun 11 2020, 11:56 PM

QUOTE(deb1 @ Jun 11 2020, 02:54 PM) *

QUOTE(pandy @ Jun 11 2020, 02:43 PM) *

We already talked about this. Use DIV to group things together or when no other block level element fits.

SPAN is similar to DIV in that it lacks features in itself, but it's inline (text level). If you want a word to stand out because it's important, you'd probably use EM and style it to your heart's content.

CODE
This is <em>important</em>.


But if you want to make all words have different colors because you think it looks pretty (just a dumb example), you don't want to use a meaningful element, but you still need something to apply CSS to, so SPAN is your choice.

CODE
<span>Nothing</span> <span>here</span> <span>is</span> <span>of</span> <span>importance</span>.


In the first example important will stand out even without CSS. The browser may make it bold or italic. In the second example all the words will look the same without CSS. SPAN doesn't carry any meaning.
\


OK understand it now . thank you again for explaining it to me.



You explained the <em> tag and the <span> tag which i understand now . can you please also show me the coding for the <div> tag so that i can understand that
as well smile.gif

Posted by: pandy Jun 12 2020, 04:24 AM

HTML 5 offers new elements that can be used instead of DIV in many cases. But lets pretend they don't exist.

A typical use of DIV in a HTML 4.01 page could look like this.

CODE
<div id="header">...</div>

<div id="topnav">...</div>

<div id="sidebar">...</div>

<div id="main">...</div>

<div id="footer">...</div>


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)