HTML - 在正文中插入边距

时间:2017-05-10 05:01:48

标签: html

我有一些文字,并希望使其更窄,因此它不会跨越屏幕。我输入了:

<body style="margin:20">
<body>
    SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having etc,
<body/>

然而,它似乎没有对文本做任何事情。我需要关闭我的体型标签吗?保证金是否正确使用? (我是一个非常初学者,这实际上是第一次尝试HTML)

3 个答案:

答案 0 :(得分:4)

在你的html上添加css,

<style>
body {
    border: 1px solid black;
    margin-top: 100px;
    margin-bottom: 100px;
    margin-right: 150px;
    margin-left: 80px;
    background-color: lightblue;
}
</style>

如果没有css,只需在body标签上添加样式属性

<body style="margin-top: 100px;margin-bottom: 100px;margin-right: 150px;margin-left: 80px;">

 SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having etc,

</body>

答案 1 :(得分:4)

HTML页面的基本语法是

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

</body>
</html>

<!DOCTYPE html>声明将此文档定义为HTML5

<html>元素是HTML页面的根元素

<head>元素包含有关文档的元信息

<title>元素指定文档的标题

<body>元素包含可见页面内容

  

HTML只有一个正文。   因此,请在正文中使用divspanp标记来包装您的内容。

<body style="margin:20">是错误的代码

尝试<body style="margin:20px"><body style="margin:1%">

body {
  margin: 20px;
}
<div>
  SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having etc,
</div>

答案 2 :(得分:3)

  1. 删除第二个<body>代码
  2. 将单位添加到保证金(即px)

    <body style="margin:20px">
       SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having etc,
    <body/>