Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<div> question

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought using <div id="xyz"> helps group html elements on a page.

1. If inside the <div id="xyz"> I need to put a few different sub-elements like <input id="abc"> , <select id="def">, etc. Then what's good about using <div> at all ? I mean, anyway I am going to use the id for each subelement.

2. If you apply a stylesheet to <div id="xyz"> , does it mean this style sheet will be applied to *every* elements inside this <div> ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. By default a <div> will create a block element, that is a rectangle that spans the width of its container. So it's useful for layout. Applying CSS can adjust that layout in many useful and interesting ways. It's also useful as an organizational element.

2. Many CSS rules are inherited from a parent if not overridden at the child level.
 
Alfred Peterson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj Ohadi, you are right. But there is lots of benefits of using <div> such as it makes web page light weight and need less coding if we are going to create number of web pages. It is much better than using table. Therefore I use it.
 
Mohan Mehra
Ranch Hand
Posts: 74
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic