2

So I am trying to make a simple border for a site, in css:

    html{
    border-top:3em solid #26282B;

}

I would like to have some white text on top of it, how can I do this? I tried making a class, but it always appears under the border.

Lucifer N.
  • 966
  • 3
  • 15
  • 34

5 Answers5

2

You CAN NOT make any text in the border. Use div or something.

Here is the example:

<html>
<head>
  <style>
      body{margin:0;padding:0;}
      .someclass {
          width:100%;
          height:3em;
          background-color:#26282B;
          color:white;
      }
  </style>
</head>
<body>
    <div class='someclass'>
        Sometext Here
    </div>
</body>
</html>
bprayudha
  • 1,034
  • 8
  • 14
1

You can put your text in a span or div set a class name and using left, top, right, bottom, fix the position like this: e.g class="example"

.example {
  position:absolute;
  left: 5px;
  top: 50px;
}

Elsewhere this probably help you:http://www.w3schools.com/tags/tag_legend.asp

wolver
  • 197
  • 3
  • 16
0

You can't write something on top of a border - technically yes, but for all purposes here, no, you can't.

So if you want a text on top a short dark background you write something like that:

In yo HTML:

<div>My suppa text</div>

In yo CSS:

div {
  background: #26282B;
  color: #fff;
}

<div> here being the first element inside your <body> it still would have a margin before it, that's because of the browser default style.

You can get rid of it by doing that, in yo CSS:

html, body {
  margin-top: 0;
  padding-top: 0;
}

Now I would suggest you to read about CSS resets.

Arthur Corenzan
  • 901
  • 9
  • 17
0

How about this:

<!DOCTYPE html>
<html>

<head>
  <style>
    #container {
      border: 10px solid;
      padding: 5px;
    }
    
    #title {
      float: left;
      padding: 0 5px;
      margin: -20px 0 0 30px;
      background: #fff;
    }
  </style>
</head>

<body>
  <div id="container">
    <div id="title">Border title</div>
    <p>Some content...</p>
  </div>
</body>

</html>
nircraft
  • 8,242
  • 5
  • 30
  • 46
user2845946
  • 1,755
  • 29
  • 38
0

Yes, you can.

Add this to your style:

-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #000;
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Rober
  • 1