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

CSS

Using a percentage, set the paragraph to half of its current width.

I put p { width:50%; } and Its wrong so not sure what to do.....

Thanks for your help!

Mike Casteel
Mike Casteel
7,960 Points

I am still unable to find the solution to this. Can you direct me on how you solved this? The answers below did not help.

Hey did you ever get this figured out...I tried a bunch of things and couldn't get them to pass.

Hey did you figure this out? I tried a bunch of things but couldn't get anything to pass.

Actually it does not at all.

kevinbroomall
kevinbroomall
6,643 Points

That's weird, I copied it from the answer that was accepted in the quiz after it was accepted.

CSS Foundations Stage 4: Values and Units

kevinbroomall
kevinbroomall
6,643 Points

Thank you Shantelle!

13 Answers

This challenge was giving me issues until I went back and watched the video again.

In the example the div is defined with a 700px value. So when he sets the paragraph to change to {width: 50%} it is taking 50% of the 700px value.

The way I solved this was by adding a value to the div in my code editor.

div { width: initial; }

p { width: 50%; }

Before I was just adding the paragraph width changes and I assume it was looking for something to scale down to 50% from but didn't have a value set.

kevinbroomall
kevinbroomall
6,643 Points

Can anyone tell me which module this is in or link the quiz? I am trying to get this fixed.

Thanks! Kevin

Have you fixed it? Guil's recommendation still doesn't work!

Thanks!

Robert Marmon
Robert Marmon
3,513 Points

I had the same issues and tried all the recommendations but his is what worked for me,, I rewrote my code inline

strong {color: initial; } div.wrapper {background-image: url('img/bg.jpg'); } p {width: 50%; }

Jessica Pascall
Jessica Pascall
1,544 Points

I have gotten everything right until this one I simply wrote p {width: 50%; } and it isn't working I've tried writing it different ways but it still isn't working

When you set width to 50% you are changing its width to 50% of the containing div. I would need to see your specific case, but view the example below:

The wrapper div containing the paragraph is 1000px wide. The paragraph is currently 500px (or 50% of the containing div). If you wanted to make it half of its current size you would need to change the width of the paragraph to 25% in this case.

Patrick Johnson
Patrick Johnson
9,505 Points

Deirdre FReeman If you're looking for a manageable way to offer up sizing based on parent relationships you should definitely check out SASS/Compass. It's offers ways to be more semantic with your mark up while also creating a really organized way to write code, especially in instances when you want an element to span a particular width of the parent.

Brent E Gust
Brent E Gust
5,540 Points

I was having the same problem. In task #2 it will accept the answer without a closing } bracket. so double check that you have properly closed your statement from the second part of the challenge.

Jacob Shirley
Jacob Shirley
6,828 Points

I had to watch the video again, and retype p { width:50%; } several times until I got it to accept. I did not have to include a width to the div, or .wrapper.

karl De Cicmic
karl De Cicmic
5,815 Points

I have just had the same problem with this. I watched the video again and my answer to this is p {width:50%;} and worked. The first time around though, it didn’t work for me.

hi ! i realize this problem as well. so i manage to use inline style to bypass it .

<p style="width:50%;">

Change your second challenge to background-image instead of content. .wrapper { background-image: url('img/bg.jpg');}

p { width: 50%; }

I am stuck on this challenge as well. I tried every suggestion but it still does not work. This is my code... strong {color: initial;} div { width: 800px; padding: 2em; margin: auto; background-image: url('bg.jpg'); }

p { width:50%; }

Guil Hernandez
Guil Hernandez
Treehouse Teacher

Hi shantelle smith,

Like Jacob mentioned, you do not need to give the div a width, padding, or margins –– keep the div as is. p { width:50%; } should take care of it. :)