Why can't I style my paragraph with css padding? [closed] - html

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm a newbie to html and CSS, and I've been trying to style my paragraph to have 5px of padding on each side of the text, but whenever I add "padding: 5px;" it gets rid of the background colour (of the paragraph), and the padding makes no effect. I've tried with just the padding and that doesn't work either. Thank you in advance!
HTML and CSS for reference:
body {
background-color: #000000;
font-family: arial;
color: white;
}
a {
color: orange;
}
p {
background-color: #393939
padding: 5px;
}
<!doctype html>
<html>
<head>
<title>spam</title>
</head>
<body>
<link rel = "stylesheet" href="main.css">
<img src = "">
<h1><strong>Website name</strong></h1>
<ul>
Home
News
</ul>
<p>
Man stabbed in ...
</p>
</body>
</html>

In CSS you need to end each property you add with a ; so simply change the code to:
p {
background-color: #393939;
padding: 5px;
}
Not having the ; to show that a property ended meant the browser read the CSS as one big property that doesn't exist, which is why it seemed like your CSS did nothing.

You are missing the ; after background-color: #393939

Related

CSS Font Not Formatting [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am beginning to code in HTML and CSS, and am using the FreeCodeCamp tutorials to help me. Along with my learning I am creating a simple webpage of my own as a project to work on.
Having learnt how to use fonts from the Internet in my webpage, I tried to change the font, colour and size of my header, but when I run the code, this doesn't show up on my webpage.
If it helps, I am using PyCharm for this (I'm not really sure what IDE to use- and I already use PyCharm so I though I'd continue with that).
<link href="https://fonts.googleapis.com/css?family=Lobster"
rel ="stylesheet" type="text/css">
<style> <!--Why doesn't this work?-->
h1 {
font-family: Lobster;
font-size: 50px:
color: red;
}
</style>
<body>
<h1> This is the h1 text which should be formatted.</h1>
your CSS comment is wrong /* CSS Comment */
<link href="https://fonts.googleapis.com/css?family=Lobster"
rel ="stylesheet" type="text/css">
<style> /* Why doesn't this work? */
h1 {
font-family: Lobster;
font-size: 50px;
color: red;
}
</style>
<body>
<h1> This is the h1 text which should be formatted.</h1>
</body>
https://jsfiddle.net/lalji1051/x0odt5qk/2/
There is an error in your css at this line: font-size: 50px: should be ; instead of : at the end of line.

Simple html link wont work [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I'm having difficulty pinpointing whats preventing the following link from working.
I chose a random link (w3schools) to test it before I linked it to what its meant for.
I thought the problem may have to do with the CSS.
ul {
font-family: 'Montserrat';
font-size: 15px;
color: #994f00;
}
#innerNav {
/*adding a relative or absolute here will break sticky*/
background-color: black;
color: white;
left: 0px;
overflow: hidden;
height: 1300px;
width: 150px;
z-index: -1;
white-space: nowrap;
list-style-type: none;
}
<!DOCTYPE html> <!-- HTML 5 -->
<html lang="en">
<body>
<div class= 'wrapper'>
<div id = 'innerNav'>
<li>
<ul>The Door</ul>
<ul>Mr Pointy</ul>
<ul>Block Rain</ul>
</li>
</div>
</div>
</body>
</html>
But even when I comment out the last line of the innerNav, the link still doesn't work (clicking it doesn't open anything).
Any ideas?
also my git files for this is:
Portfolio
The problem has nothing to do with the link and everything to do with the fact that you have the z-index of your #innerNav set to -1. So you are covering your navigation up with the .wrapper. So just remove the z-index from the innerNav completely or just set it to 1.
PS the markup for this is invalid as well you may want to look up the correct markup for an unordered list it should be as follows:
<ul>
<li></li>
<li></li>
</ul>
For some reason you have it backwards with <ul> nested inside of <li> it should be the other way around.

Css style is not applied in Firefox [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
This is very dumb question. But I do not know how to solve the issue.
I have the following html/css code
<!DOCTYPE html>
<html>
<head>
<title>Selectors and Grouping</title>
<style type=”text/css”>
p {
font-family: Arial;
font-size: 14pt;
}
h1 {
color: black;
border: 5px solid black;
}
h2 {
color: orange;
border: 4px solid orange;
}
h3 {
color: blue;
border: 3px solid blue;
}
h1,
h2,
h3 {
letter-spacing: 5px;
padding: 10px;
}
</style>
</head>
<body>
<h1>
Heading 1
</h1>
<h2>
Heading 2
</h2>
<h3>
Heading 3
</h3>
<p> Selectors choose the element to apply formatting to. grouped together.
</p>
</body>
</html>
html headings must be enclosed in boxes and have different colours. However, when I open the document in Firefox browser it displays the page without any style applied. Online validators point to no error. So the issue must be related to firefox. Can anybody help me?
Thanks in advance.
The issue comes from this part :
<style type=”text/css”>
Your quotes are not the good ones. Use :
<style type='text/css'>
You have following errors :
1) There were incorrect quotes in <style type=”text/css”>. Change it to proper double quote:
<style type="text/css">
2) You are missing one < in doctype declaration as per above code you have mentioned in question.
3) You haven't closed the <html> tag
look at your style tag :
<style type=”text/css”>
change to normal double quote
<style type="text/css">
and close you html tag at the end

CSS font color style not applied [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Why is the font color for paragraph text not changing to red?
I haven't applied any other CSS styles, so this shouldn't be an issue with style overriding right?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
p {
color=red;
}
</style>
</head>
<body>
<p id="msg1">message 1</p>
</body>
</html>
color: red; would be the correct CSS-syntax. Good luck!
CSS syntax error...
use ':' instead of '=' inside the style..
You have an error in your CSS syntax.
<style>
p {
color: red;
}
</style>
You could also target with the ID by using
<style>
#msg1 {
color: red;
}
</style>

<style> tag in HTML file not showing up in browser [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have just started learning html and css.
While reading a tutorial from a book I saw how to change the styles
I wrote the same code but there is no effect on the page in the browser.
It appears just the same as without the <style> tag.
Here's the code:
<title> Starbuzz Coffee </title>
<style type=”text/css”>
body {
background-color: #d2b48c;
margin-left: 20%;
margin-right: 20%;
border: 1px dotted gray;
padding: 10px 10px 10px 10px;
font-family: sans-serif;
}
</style>
Change <style type=”text/css”> to <style type="text/css">.
The key problem here is with your quote. I've just tested using ” which didn't work in my local project.
Your quotation marks are the issue, you need to use " instead of ”
Like this:
<style type="text/css">
Also, lets go to the next level too. Adding styles in the HTML head is ok, but you will find it a lot easier to maintain your HTML and CSS code in the future if you link to a separate stylesheet. To do that, just add the following to your HTML head:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
In this case your stylesheet is called 'mystyle.css' and is located in the same folder as your HTML page...
You can now add all of your CSS goodness into the 'mystyle.css' file like this:
body {
background-color: #d2b48c;
margin-left: 20%;
margin-right: 20%;
border: 1px dotted gray;
padding: 10px 10px 10px 10px;
font-family: sans-serif;
}
Read more about this on W3 Schools.
You can try couple of thing to test
Open a debugger window by pressing F12 and find body tag to see what has overwritten it.
Try inline style on a body tag and see does that make a difference
Change the order of a CSS on your page.