Problem with margins and see the web in smartphones

Hi everybody!,

I have two issues with my tribute page, first I dont get put mrgins to my web page I would like that my web to have white margins and the background not occupy the whole web.

The second problem is that the web dont the web does not look good on smartphones I have tried with responsive class, but I dont know where the problem is.

And third quiestion ¿How can I post the code here without make a mess :sweat_smile:, I have post the code ten minutes ago and the result was…:astonished:…horrible. Sorry for my few experience using this web.

And this the web

Thank you for reading!

If you want to post your code use three backticks (```) before and after your block of code. See this.

Also, you have your html structured incorrectly. You want to restructure it like this

<html>
  <head>
    <!-- Stuff that goes in the head -->
  </head>
  <body>
    <!-- Stuff that goes in the body -->
  </body>
</html>      

But on codepen, you can omit the html and head elements and just start with the body.

thank you a lot for you response, has been very useful to mee! :slightly_smiling_face:

If you add the class img-responsive to your image tag that will make the image smaller (and get rid of the scroll bar) on smaller devices.

Thank you for the response now I have new problems :disappointed_relieved:

The ul element (list) appear too much at right in smartphones screens

I want to put margins at the blue-light background but I dont know how do it, I tried body-background and the propierties margin-top, margin-right, margin-bottom and margin-left, (actually I have deleted then because dont work).

Other thing is that my elements and dont appear at left but the code is the same that I have used in

element and in this element work well.

My code is this

<div class="container-fluid">

    <div class="text-center">

  <div class="responsive">

  <style type="text/css">

    A:link, A:visited { text-decoration: none;}

      body {width:100%; font-family: "Aref Ruqaa"; font-size: 22px; text-align: center;} 
  
 .smaller-image{
    width: 500px;

  }
    h3 {
    font-family: Lobster, Monospace;
      font-size: 25px;

  }
    .thick-green-border {
    border-color: #2998E4;
    border-width: 5px;
      border-style: solid; background: #b0c6f8; padding-top: 3px; padding-bottom: 10px; border-radius: 10px;}
      .p-margin {margin-bottom: 75px;}
      .p-sign {font-family: Arial; font-size: 15px; margin-bottom: 50px}
      
      h4 {font-family:"Aref Ruqaa";font-size: 25px; color: black;}
      h5 {font-family:"Aref Ruqaa";font-size: 25px; color: black;}
      h6 {font-family:"Aref Ruqaa";font-size: 25px; color: black;}
      ul {margin: 25px; margin-left: 280px; font-family: Arial; font-size: 17px; color: black;}
      .font-style {font-family: Arial; font-size: 17px; color: black;}
      h1 {color: white;} 
    .buttons{font-size: 20px;} 
      container{
        text-align:center;}
      a{font-family:Arial;
      font-size: 16px;}
      A:link, A:visited { text-decoration: none;}
.class1 {font-family: Arial; font-size: 17px; color: black;}
 </style>                    

      <head>
        
<link href="https://fonts.googleapis.com/css?family=Aref Ruqaa" rel="stylesheet" type="text/css"> 
            <div class=container>
  <h1 class=thick-green-border><b> John Ronald Reuel Tolkien</b></h1>
        
<h2> 1892-1973 </h2>
<img class="smaller-image" src="https://ichef-1.bbci.co.uk/news/660/cpsprodpb/14364/production/_96288728_tolk1.jpg" class="img-responsive" alt= "Tolkien">
<h3 class="responsive">Father of the modern medieval fantasy books. Tolkien was the creator of a world full of magic and all kind of creatures like dragons and elves.</h3
  </head>
 <body>
<body style="background-color:  #ebf5fb;">
  <div class="responsive">
<div class="container-fluid container">
  <a href="#one"><button class="buttons btn btn-primary">Biography</button>
   <a href="#two"><button class="buttons btn btn-primary">Bibliography</button>
  <a href="#three"><button class="buttons btn btn-primary">Links</button>
  <h4 class="thick-green-border">
   Biography </h4>
     <p id="one" align="left" class="font-style">Tolkien was born in Sout Africa, son of a banker and a missionary. In 1895 he moved with his mother Mabel Suffield und his brother Hilary to England. His father Arthur Reuel Tolkien  stayed in south africa but he died in 1896.</p>
<p class="font-style" align="left" >After the loss of her husband, And without income Mabel moved with her children to Sarehole. The English countryside was very inspiring for Tolkien's work as we see in his books. </p>
<p class ="font-style" align="left" >Mabel was in charge of the education of John and taught him Latin. From the age of four, one of Jhon's favorite hobbys was to create his own languages.</p>
    <p class ="font-style" align="left" >In 1904, when John was 12 years old, his mother died, the pastor Xavier Morgan looked after then of Jhon and his brother Hilary.</P>

<p class ="font-style" align="left" >When he was 19, traveled to the Alps, a place that inspired him to describe Bilbo's journey through the Misty Mountains, in "The Hobbit".</p>

<p class ="font-style" align="left" >At 23 years he married with Edith Mary Bratt, a girl he had met years ago at the orphanage.</p>
<p class ="font-style" align="left" >In 1914 he wrote the poem "The Voyage of Éarendel the Evening Star", which many consider the genesis of his work. That year began the First World War which would interrupt his peaceful life.</p>


<p class ="font-style" align="left" >In 1915 John graduated in Oxford with a honorable mention in "Literature and English Language", soon after graduating, he enlisted in the army as a communications officer. The First World War, was a tragedy unprecedented for all the countries. In the war, Jhon lost his friends Robert Q. Gilson  and G.B.Smith.</p> 
<p class ="font-style" align="left"> On October 27 of 1916, John became ill ,on 8 November was transferred to England. After returning to his country he began working on the writing of the Oxford English Dictionary, until 1920 when he got a job as a non-English teacher at the University of Leeds,he soon obtained the post of professor. Jhon worked most of his life for the University of Oxford, although he also worked for other universities in jobs related to the English language. </p>
<p class ="font-style" align="left"> In his spare time, John was with his family and wrote. He wrote stories and legends that years later became in "The Silmarillion", for him it was a way to compensate that England did not have its own mythology.
</p>

<p class ="font-style" align="left">In 1926 he met C.S. Lewis, another college professor who like him was fascinated by fantastic literature</p>

<p class ="font-style" align="left"> Jhon had four children and began writing "The Hobbit" for them. He thought his stories would not interest the public, but his friend C.S. Lewis encouraged him to publish them. The story was published in 1937, and was a great success that surprised Tolkien, then his editor asked him to write a sequel and in this way John began to write his masterpiece "The Lord of the rings". It took twelve years to write this great work and because of its volume was divided into three parts: "The fellowship of the ring", “The two towers” (1954) and “The Return of the King” (1955).</p>

<p class ="font-style" align="left"> While working on the writing of Lord of the Rings, he wrote other stories like 'Leaf, by Niggle', 'Egidio, Ham's Farmer' and at his aunt's request "" The adventures of Tom Bombadil and other poems Of the Red Book '(a compilation of 16 poems).  Before dying he wrote three more histories: "Three and Leaf", the poem "Mitopeia" and "The blacksmith of Wootton Mayor"</p>

<p class ="font-style" align="left">John retired in 1959 and in 1968 moved with Edith to Bournemouth, looking for more privacy. In In 1971 Judith died and John wrote on his tombstone the word "Lúthien". Jhon died in 1973 and both are buried in Oxford's Wovercote Cemetery. A year and a half before her death, Queen Elizabeth II appointed him "Commander of the Order of the British Empire" and Oxford University appointed him "Doctor Honoris Causa in Letters"</p>
<h5 class="thick-green-border">
   Bibliography</h5>
    <p1 id="two" align="left" class="font-style">Throughout his life Tolkien wrote many works and different styles. Below you can see a list with the most important.</p>
     
     <ul><li>1937 "The Hobbit"</li><li>1945 "Leaf by Niggle"</li><li>1945 "The Lay of Aotrou and Itroun"</li><li>1949 "Farmer Giles of Ham"</li><li>1953 "The Homecoming of Beorhtnoth Beorhthelm's Son"</li><li> 1954 "The Lord of the Rings"</li><li>1962 "The Adventures of Tom Bombadil"</li> <li>1964 "Tree and Leaf"</li><li>1966 "The Tolkien Reader"</li><li>1967 "The Road Goes Ever On"<li>1967 "Smith of Wootton Major"</li> </ul>
   
     <h6 class="thick-green-border">Links</h6>
     <p2 id="three" class="font-style">If you want to read more about his biography visit <a href="https://en.wikipedia.org/wiki/J._R._R._Tolkien">this link</a></p2>
     <p class="p-margin font-style">If you want to know all his bibliography visit <a href="https://en.wikipedia.org/wiki/J._R._R._Tolkien_bibliography">this link</a></p>
     <p class="p-sign">Written and code by Verónica Almeneiro</p>
</div>
    </div>
    </div>
  </div>
  </body>

And this is my code pen until now

Thank you for reading!

So, for now, I would suggest just focusing on the user stories for this project.

  1. I can view a tribute page with an image and text.

  2. I can click on a link that will take me to an external website with further information on the topic.

There’s nothing saying that you can’t come back to this project later to improve on it. Debugging and testing will be much easier for you and others if you get into the habit of neatly formatting your code and commenting your code. If I just copy your code out of codepen and paste it into an editor, it’s kind of a mess. Please don’t take this as an insult, because that’s not how I mean it.

To start with, take all of the CSS inside of that style element, put it into the CSS pane in codepen, and get rid of the style element in the HTML. Next, go back and reformat everything so that you have everything correctly indented. This isn’t necessarily going to fix the issues you are having, but it will make it easier for you to see what you have. Also, the .font-style class you have looks to be applied in almost all of your p elements. The things you’re specifying in this class are general enough that they could be applied to the entire page, for example in the body element.

1 Like

Hi Matt,

Thank you for you response :slightly_smiling_face:, I have saw the mess that the code only copy and paste is :frowning:, one question when you say “formatting your code and commenting”, that mean that I must write the code here in the post?.

Thank you again for you help :slightly_smiling_face:

What I mean is, when you are writing your code (not just when posting it here), you should get into the habit of formatting it with whitespace (tabs, vertical spaces, etc) so that it is easier to read. For example:

<body>
  <h1>Some Interesting Heading</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
     tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
     quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 
     consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum 
     dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, 
     sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

  <!--Add comments to explain what blocks of code do -->
  <ul>
    <li>Item 1</ul>
    <li>Item 2</ul>
    <li>Item 3</li>
  </ul>
</body>

This is much easier to read and understand and will only help you in the long run to make sense of your code.

This is what your code looks like when reformatted:

<div class="container-fluid">
  <div class="text-center">
    <div class="responsive">
      <style type="text/css">
        A:link, A:visited {
          text-decoration: none;
        }
        body {
          width:100%;
          font-family: "Aref Ruqaa";
          font-size: 22px;
          text-align: center;
        }   
        .smaller-image{
          width: 500px;
        }
        h3 {
          font-family: Lobster, Monospace;
          font-size: 25px;
        }
        .thick-green-border {
          border-color: #2998E4;
          border-width: 5px;
          border-style: solid;
          background: #b0c6f8;
          padding-top: 3px;
          padding-bottom: 10px;
          border-radius: 10px;
        }
        .p-margin {
          margin-bottom: 75px;
        }
        .p-sign {
          font-family: Arial; 
          font-size: 15px; 
          margin-bottom: 50px;
        }
          
        h4 {
          font-family:"Aref Ruqaa";
          font-size: 25px; 
          color: black;
        }
        h5 {
          font-family:"Aref Ruqaa";
          font-size: 25px; 
          color: black;
        }
        h6 {
          font-family:"Aref Ruqaa";
          font-size: 25px; 
          color: black;
        }
        ul {
          margin: 25px; 
          margin-left: 280px; 
          font-family: Arial; 
          font-size: 17px; 
          color: black;
        }
        .font-style {
          font-family: Arial; 
          font-size: 17px; 
          color: black;
        }
        h1 {
          color: white;
        } 
        .buttons {
          font-size: 20px;
        } 
        container {
          text-align:center;
        }
        a {
          font-family:Arial;
          font-size: 16px;
        }
        A:link,
        A:visited { 
          text-decoration: none;
        }
        .class1 {
          font-family: Arial; 
          font-size: 17px; 
          color: black;
        }
        li {
          display:block;
        }
      </style>                    

      <head>  
        <link href="https://fonts.googleapis.com/css?family=Aref Ruqaa" rel="stylesheet" type="text/css"> 
          <div class=container>
            <h1 class=thick-green-border><b> John Ronald Reuel Tolkien</b></h1>    
            <h2> 1892-1973 </h2>
            <img class="smaller-image" src="https://ichef-1.bbci.co.uk/news/660/cpsprodpb/14364/production/_96288728_tolk1.jpg" class="img-responsive" alt= "Tolkien">
            <h3 class="responsive">Father of the modern medieval fantasy books. Tolkien was the creator of a world full of magic and all kind of creatures like dragons and elves.</h3
      </head>
      <body>
       <body style="background-color:  #ebf5fb;">
         <div class="responsive">
           <div class="container-fluid container">
             <a href="#one"><button class="buttons btn btn-primary">Biography</button>
               <a href="#two"><button class="buttons btn btn-primary">Bibliography</button>
                 <a href="#three"><button class="buttons btn btn-primary">Links</button>
                   <h4 class="thick-green-border">Biography </h4>
                   <br>
                   <p id="one" align="left" class="font-style">
                     Tolkien was born in Sout Africa, son of a banker and a 
                     missionary. In 1895 he moved with his mother Mabel Suffield 
                     und his brother Hilary to England. His father Arthur Reuel 
                     Tolkien  stayed in south africa but he died in 1896.
                   </p>
                   <p class="font-style" align="left" >
                     After the loss of her husband, And without income Mabel moved 
                     with her children to Sarehole. The English countryside was 
                     very inspiring for Tolkien's work as we see in his books. 
                   </p>
                   <p class ="font-style" align="left" >
                     Mabel was in charge of the education of John and taught him 
                     Latin. From the age of four, one of Jhon's favorite hobbys was 
                     to create his own languages.
                   </p>
                   <p class ="font-style" align="left" >In 1904, when John was 12 
                     years old, his mother died, the pastor Xavier Morgan looked 
                     after then of Jhon and his brother Hilary.
                   </P>
                     <p class ="font-style" align="left" >
                       When he was 19, traveled to the Alps, a place that inspired 
                       him to describe Bilbo's journey through the Misty 
                       Mountains, in "The Hobbit".
                     </p>
                     <p class ="font-style" align="left" >At 23 years he married 
                       with Edith Mary Bratt, a girl he had met years ago at the 
                       orphanage.
                     </p>
                     <p class ="font-style" align="left" >
                       In 1914 he wrote the poem "The Voyage of Éarendel the 
                       Evening Star", which many consider the genesis of his work. 
                       That year began the First World War which would interrupt 
                       his peaceful life.
                     </p>
                     <p class ="font-style" align="left" >
                       In 1915 John graduated in Oxford with a honorable mention 
                       in "Literature and English Language", soon after graduating, 
                       he enlisted in the army as a communications officer. The 
                       First World War, was a tragedy unprecedented for all the 
                       countries. In the war, Jhon lost his friends 
                       Robert Q. Gilson  and G.B.Smith.
                     </p> 
                     <p class ="font-style" align="left">
                       On October 27 of 1916, John became ill ,on 8 November was 
                       transferred to England. After returning to his country he 
                       began working on the writing of the Oxford English 
                       Dictionary, until 1920 when he got a job as a non-English 
                       teacher at the University of Leeds,he soon obtained the post 
                       of professor. Jhon worked most of his life for the 
                       University of Oxford, although he also worked for other 
                       universities in jobs related to the English language.
                     </p>
                     <p class ="font-style" align="left">
                       In his spare time, John was with his family and wrote. He 
                       wrote stories and legends that years later became in 
                       "The Silmarillion", for him it was a way to compensate that 
                       England did not have its own mythology.
                     </p>
                     <p class ="font-style" align="left">
                       In 1926 he met C.S. Lewis, another college professor who 
                       like him was fascinated by fantastic literature
                     </p>
                     <p class ="font-style" align="left">
                       Jhon had four children and began writing "The Hobbit" for 
                       them. He thought his stories would not interest the public, 
                       but his friend C.S. Lewis encouraged him to publish them. 
                       The story was published in 1937, and was a great success 
                       that surprised Tolkien, then his editor asked him to write 
                       a sequel and in this way John began to write his masterpiece 
                       "The Lord of the rings". It took twelve years to write this 
                       great work and because of its volume was divided into 
                       three parts: "The fellowship of the ring", 
                       “The two towers” (1954) and “The Return of the King” (1955).
                     </p>
                     <p class ="font-style" align="left">
                       While working on the writing of Lord of the Rings, he wrote 
                       other stories like 'Leaf, by Niggle', 'Egidio, Ham's Farmer' 
                       and at his aunt's request "" The adventures of Tom Bombadil 
                       and other poems Of the Red Book '(a compilation of 16 poems).
                       Before dying he wrote three more histories: "Three and Leaf", 
                       the poem "Mitopeia" and "The blacksmith of Wootton Mayor"
                     </p>
                     <p class ="font-style" align="left">
                       John retired in 1959 and in 1968 moved with Edith to 
                       Bournemouth, looking for more privacy. In In 1971 Judith 
                       died and John wrote on his tombstone the word "Lúthien". 
                       Jhon died in 1973 and both are buried in Oxford's Wovercote 
                       Cemetery. A year and a half before her death, Queen 
                       Elizabeth II appointed him "Commander of the Order of the 
                       British Empire" and Oxford University appointed him "Doctor 
                       Honoris Causa in Letters"
                     </p>
                     <br>
                     <h5 class="thick-green-border">Bibliography</h5>
                     <p id="two" align="left" class="font-style">
                       Throughout his life Tolkien wrote many works and different 
                       styles. Below you can see a list with the most important.
                     </p>
                     <ul>
                       <li>-1937 "The Hobbit"</li>
                       <li>-1945 "Leaf by Niggle"</li>
                       <li>-1945 "The Lay of Aotrou and Itroun"</li>
                       <li>-1949 "Farmer Giles of Ham"</li>
                       <li>-1953 "The Homecoming of Beorhtnoth Beorhthelm's Son"</li>
                       <li> -1954 "The Lord of the Rings"</li>
                       <li>-1962 "The Adventures of Tom Bombadil"</li>
                       <li>-1964 "Tree and Leaf"</li>
                       <li>-1966 "The Tolkien Reader"</li>
                       <li>-1967 "The Road Goes Ever On"
                         <li> -1967 "Smith of Wootton Major"</li>
                      </ul>
                      <br>
                      <h6 class="thick-green-border">Links</h6>
                      <br>
                      <p2 id="three" class="font-style">
                        f you want to read more about his biography visit 
                        <a href="https://en.wikipedia.org/wiki/J._R._R._Tolkien">this link</a>
                      </p2>
                      <p class="p-margin font-style">
                        If you want to know all his bibliography visit 
                        <a href="https://en.wikipedia.org/wiki/J._R._R._Tolkien_bibliography">this link</a>
                      </p>
                      <p class="p-sign">Written and code by Verónica Almeneiro</p>
                    </div>
                  </div>
                </div>
              </div>
            </body>

This makes it much easier to read. Now you can see you have some elements that need to be closed, especially the div’s and a’s. There are several a’s that need to be closed. The way you have them now, it’s like having an a element inside of another a element inside of another a element, all with the remaining code inside of the most inner a element. Also, you have a link, a div some headings and an image inside of a head. The head element is for metadata, you wouldn’t place these things inside the head. There’s also an opening body tag, followed immediately by another opening body tag–you only need one.

1 Like

Thanks for your answer, and for putting the code correctly, really is more clear :slightly_smiling_face:. I will consider your advice.