Title: I try to get a border around the header with CSS using ID. But the border will not show?
Tags: html;css
Question: This is the HTML coding and it is this main header that I want to have a border around.
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,700;1,300&amp;display=swap');
body {
font-family: "Roboto Condensed", sans-serif;
font-weight: 300 !important;
margin: 0px;
margin: 0px;
body h1 {
font-weight: 300;
#main-header {
border: 1px solid #000;
<body&gt;
<header id="main header"&gt;
<h1&gt;Best news ever!</h1&gt;
</header&gt;
</body&gt;
I hope someone can see what I do wrong.
Comment: You don't have a dash in your html. Needs to be `id="main-header"`

Here is the accepted answer: Looking at your HTML markup the opening body tag isn't being closed properly and your <header id=&quot;main-header&quot; is missing a hyphen - should look like the below:
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,700;1,300&amp;display=swap');
body {
font-family:"Roboto Condensed", sans-serif;
font-weight:300 !important;
margin:0px;
margin:0px;
body h1 {
font-weight:300;
#main-header {
border: 1px solid #000;
<body&gt;
<header id="main-header"&gt;
<h1&gt;Best news ever!</h1&gt;
</header&gt;
</body&gt;


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:09/16/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<html><css>', 'Title': 'I try to get a border around the header with CSS using ID. But the border will not show?', 'ViewCount': 27, 'id': 63925538, 'user_AboutMe': None, 'user_AccountId': 19526248.0, 'user_DisplayName': 'user14287044', 'user_Reputation': 3.0, 'user_Views': 1.0, 'user_id': 14287044.0}}