Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
akshaythakur
Courses Plus Student 34,019 PointsHTML and CSS Design problem
Hi, I am complete beginner to html and css.I want some hands on experience on both html and css so decided to develop simple layout but i am struck in header div.
<div class="heading"> <h3>HTML</h3> <p>New</p> </div>
i define below css rule...
.heading h3{ width:60%; } .heading p{ display:inline; float:right; }
i want my heading<h3>on left hand side and <p> on right hand side ....each on same line...but <p> is getting on next line to right hand side.I want following output.
|**********HTML ********************************* New*********|
1 Answer
Saskia Lund
5,673 PointsHi Akshay!
To achieve the desired layout try the following CSS and delete the heading rules you already wrote. Those are ineffective, because there is nothing in your html code that has a heading class assigned.
* {
box-sizing: border-box;
}
h3.left {
float: left;
text-align: center;
width: 33.3%; /* h3 is a block element that occupies the entire width of its parent element. thus set its width to something smaller */
margin: 0;
padding: 0;
}
span.title {
text-align: center;
display: inline-block;
width: 100%;
font-weight: bold;
font-size: 1.17em;
margin: 0;
padding: 0;
}
p.right {
width: 66.7%;
float: right;
margin: 0;
padding: 0 5%;
text-align: justify;
}
.clear:after {
content: ".";
clear: both;
display: block;
visibility: hidden;
height: 0px;
}
change your html like this:
<h3 class="left">HTML</h3>
<p class="right clear"><span class="title">New</span>some text</p>
Hope this helped!
Saskia
akshaythakur
Courses Plus Student 34,019 Pointsakshaythakur
Courses Plus Student 34,019 Pointsthanks alot........