Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 15th, 2013, 6:31 PM   #1
BenRobertson
Newbie
 
Join Date: Nov 2012
Posts: 8
Rep Power: 0 BenRobertson is on a distinguished road
Is empty div tags a bad practice?

Hi there,

Just wondering weather using <div> without any text inside them is bad practice?

Example:

<div id="background"></div>

And the CSS:

    #background {
    background-color: #f5f5f5;
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 1;
    text-align: center;
}

Is there a better way to make backgrounds, have certain empty color effects on the page or is an empty div tag the best way to go about this?
BenRobertson is offline   Reply With Quote
Old Mar 15th, 2013, 9:02 PM   #2
SteveO
Hobby Programmer
 
SteveO's Avatar
 
Join Date: Nov 2010
Location: Texas
Posts: 693
Rep Power: 7 SteveO is on a distinguished road
Re: Is empty div tags a bad practice?

You could write the stylesheet like so:

CSS Syntax (Toggle Plain Text)
  1. body {
  2. /* Other styles here */
  3. background-color: #f5f5f5;
  4. }

You can then attach the stylesheet like so:

HTML Syntax (Toggle Plain Text)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- Whatever you need here, including script and meta tags -->
  5.  
  6. <!-- Attach stylesheet -->
  7. <link rel="stylesheet" type="text/css" ref="/path/to/file/style.css">
  8. </head>
  9. <body>
  10. <!-- Content goes here -->
  11. </body>
  12. </html>

It's never really a good idea to leave stuff that is useless in a web page.
__________________
"I have no special talent. I am only passionately curious."
SteveO is offline   Reply With Quote
Old Mar 15th, 2013, 11:44 PM   #3
BenRobertson
Newbie
 
Join Date: Nov 2012
Posts: 8
Rep Power: 0 BenRobertson is on a distinguished road
Re: Is empty div tags a bad practice?

Thanks, wasn't sure about it.
BenRobertson is offline   Reply With Quote
Reply

Bookmarks

Tags
div, html

« Previous Thread in Forum | Next Thread in Forum »

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
Calling a function from within itself. Bad practice? Blackouti386 C++ 8 Dec 2nd, 2011 2:22 PM
CSS template problem with Joomla, please help josh305 HTML / XHTML / CSS 0 Dec 29th, 2010 2:59 PM
Is calling destructor from the constructor a bad practice? magnus C++ 11 Nov 2nd, 2009 3:30 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC