aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes <div> question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "<div> question" Watch "<div> question" New topic
Author

<div> question

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 314
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

Joined: Jan 10, 2002
Posts: 56540
    
  14

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Alfred Peterson
Greenhorn

Joined: Aug 17, 2010
Posts: 12
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.


emule
Mohan Mehra
Ranch Hand

Joined: Jul 28, 2011
Posts: 63
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_div_test
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: <div> question
 
Similar Threads
Eric, come in please
how to call a struts tag using innerHTML
focus() not working in firefox
javascript to insert table and its data into html div tag
showing fields dynamically