Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Closed Thread
 
Thread Tools Display Modes
Share |
  #1  
Old 08-18-2014, 04:51 AM
fradlong fradlong is offline
Junior Member
 
Join Date: 08-07-14
Posts: 12
iTrader: 0 / 0%
Div and Class difference

what is the difference between div and class in HTML what is the benefit of using class for css when we can do our task with div ??
 

Advertisement

Advertisement

  #2  
Old 09-06-2014, 11:42 PM
arunthomas203 arunthomas203 is offline
Contributing Member
 
Join Date: 06-24-14
Posts: 68
iTrader: 0 / 0%
Quote:
Originally Posted by fradlong View Post
what is the difference between div and class in HTML what is the benefit of using class for css when we can do our task with div ??
I belive you are mentioning inline styles with styles from css. Considering a large website, it will be very easy to change the style from the css file for the elements with the same class name

for example, if you need to change the width of div that contains the main page content in all the pages

inline style
HTML Code:
<div style"width:200px">test</div>
to
HTML Code:
<div style"width:250px">test</div>
for inline style, you need to open all the html file and make the changes

from the css
HTML Code:
<div class="main-content">test</div>
css file
Code:
.css { width:250px; }
you can change the width in the css file and this will change the width in all the pages
 
  #3  
Old 09-09-2014, 08:07 AM
maxi007 maxi007 is offline
Contributing Member
 
Join Date: 09-06-14
Posts: 123
iTrader: 0 / 0%
Quote:
Originally Posted by arunthomas203 View Post

from the css
HTML Code:
<div class="main-content">test</div>
css file
Code:
.css { width:250px; }
you can change the width in the css file and this will change the width in all the pages
there is an error
replace
Code:
.main-content with .css in the css file
 
  #4  
Old 09-14-2014, 01:30 AM
arunthomas203 arunthomas203 is offline
Contributing Member
 
Join Date: 06-24-14
Posts: 68
iTrader: 0 / 0%
Thanks for noticing that.
 
  #5  
Old 09-14-2014, 11:15 AM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,637
iTrader: 5 / 100%
Here is an article explaining the difference between a div and a class: The Difference Between ID and Class

You are supposed to use only 1 div name (id) per page. A class you can use multiple times on a page.

Both can be formatted via your external CSS file which makes it easier to do site wide formatting changes instead of going to each page when inline CSS is used.
 
  #6  
Old 09-18-2014, 03:51 AM
Veeramanikandan Veeramanikandan is offline
Junior Member
 
Join Date: 07-14-14
Posts: 13
iTrader: 0 / 0%
DIV is the division or section.

the DIV is the box element. it containing the header, body, footer contents.

The class element can be used in css code .

once you are creating a class, use more than one DIVs.
 
  #7  
Old 09-23-2014, 08:56 AM
yasar yasar is offline
Banned
 
Join Date: 09-23-14
Location: bangalore
Posts: 77
iTrader: 0 / 0%
When applying CSS styles to an element in your HTML, you’ll be using different CSS selector.
Two of the most common selectors used in CSS are the “class” selector and the “ID” selector.
eg:
<div id="element">
<!-- stuff goes here... -->
</div>
your CSS
#element {
background: blue;
}
 
  #8  
Old 10-15-2014, 11:48 AM
yasar yasar is offline
Banned
 
Join Date: 09-23-14
Location: bangalore
Posts: 77
iTrader: 0 / 0%
div is used to divid one part to another part,
the class function are used to idetificatin name of specific changes..
 
  #9  
Old 10-16-2014, 03:07 PM
kiethhoyt kiethhoyt is offline
Junior Member
 
Join Date: 09-24-14
Posts: 47
iTrader: 0 / 0%
Quote:
Originally Posted by yasar View Post
div is used to divid one part to another part,
the class function are used to idetificatin name of specific changes..
Correct. The ID (#) is used for specific elements where the class (.) is used for reuse of elements. You could code your entire website with ID's, but it will be clunky and take a while to load.
 
  #10  
Old 10-16-2014, 03:09 PM
kiethhoyt kiethhoyt is offline
Junior Member
 
Join Date: 09-24-14
Posts: 47
iTrader: 0 / 0%
Quote:
Originally Posted by fradlong View Post
what is the difference between div and class in HTML what is the benefit of using class for css when we can do our task with div ??
In regard to the original question here, the class is what defines the elements of a DIV. Like others have said, you probably meant the difference between an ID and a class.
 
  #11  
Old 11-23-2014, 08:59 AM
saaek saaek is offline
Junior Member
 
Join Date: 11-23-14
Posts: 23
iTrader: 0 / 0%
Actually, you can apply styles to div or any other elements. div is a part of HTML, not CSS.
 
  #12  
Old 11-24-2014, 11:00 PM
chamath chamath is offline
Junior Member
 
Join Date: 11-17-14
Posts: 14
iTrader: 0 / 0%
In HTML DIV is an element and CLASS is a most common selector. You can apply one class for many DIVs to applying same style with CSS.
 
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting C class IPs zool007 Web Hosting Forum 1 06-05-2008 12:13 PM
Difference bet ID and class CSS http Coding Forum 1 12-07-2006 08:40 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 01:37 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC