Text-align


#1

Why span and p don’t stand in a center ?
CSS

.nature { text-align:center;
          font-size:30px;
		  color:#b8b8b8;
}

li {
    list-style-type: none; /* Убираем маркеры */
   }
#banner .content h1 {
  position: relative;
  top: 25px;
  width: 800px;
  margin: 0 auto;
  border: 3px solid white ;
  color:#2f3030;
}
#banner  { background-image: url("1.jpg");
	    font-size: 75px;
		text-align:center;
		height:700px;
		  background-size: cover;
  background-position: center;
}
body {
  background-color: white;
  font-family: "Book Antiqua";
}
p{ color:#b8b8b8;
  font-size: 23px;
  line-height: 48px;
  font-family: "Book Antiqua";
max-width:600px;
text-align:right;

 }
  
  .line{  text-align:center;

 border-bottom: 2px solid red;
  border-top: 2px solid red;
  color: Red;
  font-size: 50px;
  font-weight: 200;
  font-family: "Book Antiqua";
 }
 

HTML

<!DOctype html>
  <html>
    <head>
	<title>Journey</title>
	<link href="style.css" rel="stylesheet">
	</head>
	<body>

	  <ul class="nature">
	    <li>Adventures<br /><br /></li>
		<li>Countries</li>
      </ul>
<div id="banner">
    <div class="content">
      <h1>Journey-is very interesting!</h1>
    </div>
  </div>
  <div>
        <span class="line"><br /><br />Travel</span>


  <p> Millions of people all over the world spend their holidays travelling. They travel to see other countries and continents, modern cities and the ruinsof ancient towns, they travel to enjoy picturesque places, or just for a change of scene. It is always interesting to discover new things, different ways of life, to meet different people, to try different food, to listen to different musical rhythms.Those who live in the country like to go to a big city and spend their time visiting museums and art galleries, looking at shop windowsand dining at exotic restaurants. City-dwellers usually likea quiet holiday by the sea or in the mountains, with nothingto do but walk and bathe and lie in the sun.Most travellers and holiday-makers take a camera with them and take picturesof everything that interests them — the sights of a city, old churches and castles, views of mountains, lakes, valleys,plains, waterfalls, forests, different kinds of trees, flowers and plants, animals and birds.Later, perhaps years later, the  photos will remind them of the happy time they once had.Peopletravel by train, by plane, by boat, and by car. All ways of travelling have their advantages and disadvantages. And peoplechoose one according to their plans and destinations.If we are fond of travelling, we see and learn a lot of things that wecan never see or learn at home, though we may read about them in books and newspapers and see pictures of them on TV. The best way to study geography is to travel, and the best way to get to know and understand people is to meet them in their own homes.</p>
    </body>
  </html>

Thank you!


#2

Hey Viktoria,

Because your span and p are not part of a div.

You opened a div, before the span and p tags, but did not close nor given it an id or class.

So,

  • Close your div
  • Give it an id or class
  • Make that div be centered on the page
  • Try to structure the page in a clearer way (personal advice)

Best of luck with the rest


#3

I can not,I done all how in codecademy.


#4

Well one way to do it would be to give the div a fixed width and a margin: 0 auto;


#5

sorry ,maybe I’m doing something wrong because nothing changed)

https://www.codecademy.com/Viktoria2003/codebits/LQcuFW


#6

Okay, almost there.

Give monitor a fixed width (such as 600px for example, not auto).

Then you’ll want to find a way for your span to be centered within monitor, because right now it’s not doing that :wink:


Edit: by the way, no <br /> in your html. You should find a way to do this within your CSS sheet. But granted, that’s not the most important thing right now.


Also, don’t forget to improve your code readability. It’s a bit messy right now, and that won’t help you.

> 	  <ul class="nature">
> 	    <li>Adventures<br /><br /></li>
> 		<li>Countries</li>
>       </ul>
> <div id="banner">
>     <div class="content">
>       <h1>Journey-is very interesting!</h1>
>     </div>
>   </div>
>   <div class="monitor">
>         <span class="line"><br /><br />Travel</span>
> 
> 
>   <p> Millions of people all over the world spend their holidays travelling. They travel to see other countries and continents, modern cities and the ruinsof ancient towns, they travel to enjoy picturesque places, or just for a change of scene. It is always interesting to discover new things, different ways of life, to meet different people, to try different food, to listen to different musical rhythms.Those who live in the country like to go to a big city and spend their time visiting museums and art galleries, looking at shop windowsand dining at exotic restaurants. City-dwellers usually likea quiet holiday by the sea or in the mountains, with nothingto do but walk and bathe and lie in the sun.Most travellers and holiday-makers take a camera with them and take picturesof everything that interests them — the sights of a city, old churches and castles, views of mountains, lakes, valleys,plains, waterfalls, forests, different kinds of trees, flowers and plants, animals and birds.Later, perhaps years later, the  photos will remind them of the happy time they once had.Peopletravel by train, by plane, by boat, and by car. All ways of travelling have their advantages and disadvantages. And peoplechoose one according to their plans and destinations.If we are fond of travelling, we see and learn a lot of things that wecan never see or learn at home, though we may read about them in books and newspapers and see pictures of them on TV. The best way to study geography is to travel, and the best way to get to know and understand people is to meet them in their own homes.</p>
>     </div>
<ul class="nature">
   <li>Adventures</li>
   <li>Countries</li>
</ul>

<div id="banner">
   <div class="content">
     <h1>Journey-is very interesting!</h1>
   </div>
</div>

<div class="monitor">
   <span class="line">Travel</span>
   <p> Millions of people all over the world spend their holidays travelling. They travel to see other countries and continents, modern cities and the ruinsof ancient towns, they travel to enjoy picturesque places, or just for a change of scene. It is always interesting to discover new things, different ways of life, to meet different people, to try different food, to listen to different musical rhythms.Those who live in the country like to go to a big city and spend their time visiting museums and art galleries, looking at shop windowsand dining at exotic restaurants. City-dwellers usually likea quiet holiday by the sea or in the mountains, with nothingto do but walk and bathe and lie in the sun.Most travellers and holiday-makers take a camera with them and take picturesof everything that interests them — the sights of a city, old churches and castles, views of mountains, lakes, valleys,plains, waterfalls, forests, different kinds of trees, flowers and plants, animals and birds.Later, perhaps years later, the  photos will remind them of the happy time they once had.Peopletravel by train, by plane, by boat, and by car. All ways of travelling have their advantages and disadvantages. And peoplechoose one according to their plans and destinations.If we are fond of travelling, we see and learn a lot of things that wecan never see or learn at home, though we may read about them in books and newspapers and see pictures of them on TV. The best way to study geography is to travel, and the best way to get to know and understand people is to meet them in their own homes.</p>
</div>

Same applies to your CSS sheet btw.


#7

Yes “p” stand in the center but “span” don’t want to stand in the center :sweat_smile:


#8

I would try to instruct all elements within monitor to align centrally.


#10

So, I know I will delete this span :grin: