What is the difference between span and div?

  • 4 Replies
  • 476 Views
*

sirishasiri

  • Full Member
  • ***
  • 107
  • +0/-0
    • View Profile
What is the difference between span and div?
« on: January 08, 2018, 02:46:05 AM »
Web designing

*

kentowin

  • Kentowin
  • Jr. Member
  • **
  • 52
  • +0/-0
    • View Profile
    • Kentowin
Re: What is the difference between span and div?
« Reply #1 on: February 19, 2018, 03:00:45 AM »
The <div> tag creates a line break and by default creates a division between the text that comes after the tag as begun and until the tag ends with </div>.

The <span> tag does not create a line break similar to a <div> tag, but rather allows the user to separate things from other elements around them on a page

*

Davidsmith0143

  • Sr. Member
  • ****
  • 263
  • +0/-0
    • View Profile
    • Trucking and Logistics App Development
Re: What is the difference between span and div?
« Reply #2 on: May 03, 2018, 06:35:52 AM »
A span element is in-line and usually used for a small chunk of HTML inside a line. A div element is block-line and used to group a larger chunk of code.

*

esparkbiz

  • Website Design & Development Company
  • Newbie
  • *
  • 7
  • +0/-0
    • View Profile
    • Website Development Company
Re: What is the difference between span and div?
« Reply #3 on: September 05, 2018, 01:55:19 AM »
The difference between span and div is that a span element is in-line and usually used for a small chunk of HTML inside a line (such as inside a paragraph) whereas a div (division) element is block-line (which is basically equivalent to having a line-break before and after it) and used to group larger chunks of code.

Example of span class:

A <span> element used to color a part of a text:

<p>My mother has <span style="color:blue">blue</span> eyes.</p>

Output: 

 My mother has blue eyes and my father has dark green eyes.

Example of div class:

A section in a document that will have a light blue background color:
<div style="background-color:lightblue">
<h3>This is a heading</h3>
<p>This is a paragraph</p>
</div>

Output:

This is some text.
This is a heading in a div element
This is some text in a div element.

This is some text.

Thank you... :)

*

Randy

  • Jr. Member
  • **
  • 54
  • +0/-0
    • View Profile
Re: What is the difference between span and div?
« Reply #4 on: September 17, 2018, 06:25:44 AM »
Span allows you to separate things from the other elements around them on a page or within a document, it does not cause a line break. This is why it is perfect for in-line styling, like coloring a single word in a sentence.

div, by default, creates a line break because it is used to make separate containers or boxes within a page or document, hence the name division.

 




See Our Webmaster Tools for Windows and Mac

A1 Sitemap Generator
      
A1 Website Analyzer
      
A1 Keyword Research
      
A1 Website Download
      
A1 Website Search Engine
      
A1 Website Scraper