LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-30-2016, 12:42 PM   #1
killingthemonkey
Member
 
Registered: Mar 2011
Location: Winston-Salem, NC
Distribution: Fedora, CentOS, Linux Mint
Posts: 259

Rep: Reputation: 24
CSS and the 'display: inline-block' Element


OK, I'm working through the book, HTML5, JavaScript, and jQuery 24-Hour Trainer.

I'm not very far in, and I run into this issue. This code produces three blocks, red, green, and blue. They should be next to each other. For whatever reason, the HTML and CSS puts them one over the next.

Code:
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <style>
        .box {
            height: 200px;
            width: 200px;
            display: inline-block;
        }
    </style>
</head>

<body>
    <div class="box" style="background:red" />
    <div id="middleBox" class="box" style="background:green" />
    <div id="lastBox" class="box" style="background:blue" />
</body>

</html>
I even went so far as to copy and paste from the book, just to make sure my code was actually what the book was telling me to type. No change.

If you comment out the last square, you see the middle. If you then comment out the middle square you see the first.

Thanks for your help,
Doug

Last edited by killingthemonkey; 10-30-2016 at 12:51 PM. Reason: Correction, Punctuation, Capitalization
 
Old 10-30-2016, 01:55 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You can't use self closing tags with div's, not like some other elements like input, hr, img etc

Use explicit closing tag, <div...></div>
 
Old 10-30-2016, 02:01 PM   #3
killingthemonkey
Member
 
Registered: Mar 2011
Location: Winston-Salem, NC
Distribution: Fedora, CentOS, Linux Mint
Posts: 259

Original Poster
Rep: Reputation: 24
That was it, exactly.

Thank you.

Quote:
Originally Posted by keefaz View Post
You can't use self closing tags with div's, not like some other elements like input, hr, img etc

Use explicit closing tag, <div...></div>
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MailScanner inline signatures won't display? scottmusician Linux - Server 1 02-24-2014 03:02 PM
html5 & css, centering the canvas element S. Chapelin Programming 5 05-05-2012 02:19 AM
CSS for Aligning Inline Images devUnix Programming 7 01-20-2012 04:54 PM
HTML5 "<details>" tag display:inline, display:hidden CSS ignored (Firefox, Seamonkey) ShellyCat Programming 1 01-11-2011 10:23 PM
CSS element interaction thew00t Programming 4 01-24-2006 10:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration