How to remove the default space on top in CSS? [duplicate] - html

This question already has answers here:
Why does this CSS margin-top style not work?
(14 answers)
Closed 1 year ago.
html,
body {
margin: 0;
padding: 0;
}
.tribute-header {
background-color: black;
color: white;
}
The above is my code and I am still seeing this space. Please refer to the image attached and the arrow shows the space I want to remove. Kindly help.

Add this to your code:
*{margin:0; padding:0; box-sizing: border-box;}
So the root of every element on your website will be as above.

Related

I want to replace the text in html by using "conetnt" but doesn't work [duplicate]

This question already has answers here:
How can I replace text with CSS?
(25 answers)
Closed last year.
div
{ border: none !important; width: 400px; margin: auto; background-color: #eee !important; text-indent: -9999px;}
div::before{content: 'test';color: black;}
The ::before and ::after attribute don't change the main tag's content, but rather they add content before or after it.
https://developer.mozilla.org/en-US/docs/Web/CSS/::before

how to make a div show [duplicate]

This question already has answers here:
HTML Div border not showing
(3 answers)
Closed 2 years ago.
I am trying to make a foot print for a cool look, but it won't show
here's my code:
.footprint {
width: 100px;
height: 50px;
border-color: gray;
border: 3px;
border-radius: 20px;
}
<div class="footprint"></div>
welcome to SO!
Somebody already found a solution to your problem here:
CSS Property Border-Color Not Working
A div by default has no border-style and no border-width, therefore the border will not be shown.

Margins that don't respond [duplicate]

This question already has answers here:
Why does margin-top work with inline-block but not with inline?
(3 answers)
Closed 3 years ago.
I have a "Read more" button on Section-e that acts weird: the margins are not responding except for left one.
GitHub Repo: https://github.com/CalogerN/Conquer
Live Preview: https://calogern.github.io/Conquer/
I tried debugging, but I found nothing.
.section-e__btn {
align-self: flex-start;
margin: 28px 0px 30px 20px;
padding: 15px 30px;
background-color: white;
font-family: "Open Sans";
}
<div class="section-e__column1">
Read more
</div>
Use display: block or display: inline-block to set margins on the <a> tag.

How can I remove the space around my background-colored header in an html page? [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 5 years ago.
I just started building a webpage using html and made a simple header for it. I want the header to be exactly along the borders of the screen but there is a white space all around my header. This is how it looks:
I changed my css by setting the margin, border and outline of my header to 0. But this doesn't seem to do the work and the white space is still there. Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
<style type="text/css">
h1{
margin:0 auto;
padding:20px;
border:0;
outline:0;
background: #003399;
color: #ffffff;
font-family: "Calibri";
font-weight: normal;
}
</style>
</head>
<body>
<header>
<h1>This is my website.</h1>
</header>
</body>
</html>
I can't figure out what my error is. Please anyone help. Thanks for the attention.
By default body tag take some CSS, just add following css for this
body {
margin: 0px;
padding: 0px;
}
In all my projects I place this code just at the start of my CSS files:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
So I have more control about margins, paddings and sizes (box-sizing: border-box makes borders and padding being applied inside the container size, not as an extra size, so it's easier to play with percentage sizes).
Another option is to put normalize.css before your styles, that already includes usual corrections like these.
Add this css
body, html {
margin: 0px;
padding: 0px;
}

HTML nav bar will not touch the top of the page [duplicate]

This question already has answers here:
Weird ul list issue in my case
(2 answers)
Closed 6 years ago.
I have been working on making a horizontal navigation bar for my site, but the top of the nav bar seems to be cut off and will not touch the top of the page.
I have tried using:
* {
padding: 0;
margin: 0;
}
However, that causes me to have to add padding to everything.
Is there any other way to fix it?
Fiddle: https://jsfiddle.net/bp2jnytc/
For your <h3> elements within your unordered lists, you could try:
h3 {
margin: 0;
padding: 15px;
}
And then for your <ul> element within your <header>:
header ul {
margin: 0;
}
There is nothing wrong with it, well, at least when I copied the code to my text editor and then ran it in chrome. I believe it to be a problem with how jsfiddle is displaying the information, not to do with your code.
Remove margin-top from the ul and the h3 tag. https://jsfiddle.net/bp2jnytc/2/