r/csshelp • • Aug 20 '21

Request Newbie css help. block getting ignored when I add 1 line of code.

Hi All,

Not sure whats wrong so I figured I would ask. When I enter a line of code it completely negates the entire block. Everything looks correct on my end and its bugging me. I'm guessing the error is human and I'm just not seeing it but that doesn't make it any less frustrating!

HTML

<!DOCTYPE html>
<html>
<head>
<title>CSS Cheat Sheet</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<div class="box-1">
<h1>Hello World</h1>
<p>
                Lorem ipsum, dolor sit amet consectetur adipisicing elit. 
                Cupiditate libero laborum a quod odit deserunt porro, eaque corporis repellendus,
                nesciunt tempore ipsa eligendi tempora! Asperiores veritatis natus cum quis sit! 
                Lorem ipsum dolor, sit amet consectetur adipisicing elit. Commodi nobis rem fugit,
                nulla blanditiis voluptate accusantium tempora voluptas officiis architecto. 
                Repudiandae voluptas error ex reprehenderit fugit! Impedit minima amet libero!
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam quia amet est atque, 
                voluptatum perferendis optio nobis tempora dolore quisquam odio delectus et sunt 
                porro repudiandae? Fugiat et aliquam delectus?
</p>
</div>
</div>
</body>
</html>

CSS

body{
background-color:#f4f4f4;
color:#555555;
font-family:
    font-size: 16px;
font-weight:normal;
/* Same as above */
/* font:normal 10px Arial, Helvetica, sans-serif */
line-height:1.6em;
margin:0
}
.container{
width:80%;
margin:5px 10px;
}
.box-1{
background-color:#333;
color:#fff

}

when I add this line of code to the .box-1 class

border-right:5px red ;

all the css elements in .box-1 are ignored and it doesn't process the border. Any ideas on what I've done wrong?

6 Upvotes

10 comments sorted by

3

u/curie2353 Aug 20 '21 edited Aug 20 '21

I am also still learning CSS. I pasted your code to codepen and noticed a missed semicolon in .box-1 after the color. Other than that everything worked with border-right: red 5px solid;

I think it wouldn't show the border without specifying what kind of border it is?

https://codepen.io/yokaion/pen/wvdVVLY

2

u/MForMarlon Aug 20 '21

This. Also, your font-family has no value.

Next time, use a code block (click on the ... then select the C with a box).

1

u/icemann155 Aug 21 '21

Thank you!!! I'm sure I'll be posting more so next time I'll look further. I thought I clicked the "code inline" button but there must be another option I missed. Thank you!!

2

u/MForMarlon Aug 21 '21

Sure thing! I believe code inline is what you used in the post. That is really meant for posting one-liners or really short sections of code.

1

u/icemann155 Aug 21 '21

Thank you! I swear small typos like these are going to be the death of me!!

2

u/curie2353 Aug 21 '21

I can relate! When my code doesn’t work, I go back and look at it and 90% of the time it’s small typos like these ones. What editor are you using? VSCode is pretty good with identifying typos which can save you time.

1

u/icemann155 Aug 21 '21

Yeah I'm using VScode. I need to learn the be patient and not rush through it. I miss one small detail and that breaks the whole block of code.

1

u/icemann155 Aug 20 '21

Also new to posting code. Not sure if I did something wrong as the formatting looks absolutely horrible.

1

u/Zmodem Moderator Aug 21 '21

Hey!

For future reference, you can place four spaces on each new line before your code, and those lines will be treated like code.

This is code { with four spaces};

.sample-class { display: none; }

You can also use ticks to make inline code blocks, {just like this}.

`ticks`

1

u/icemann155 Aug 21 '21

Thank you!