Skip to content Skip to sidebar Skip to footer

Why Paragraph Don't Align Next To Image In Html?

I'm learning frontend web design and i'm trying to build a fully responsive blog like static page. But my problem is the image are not aligning properly with the paragraph. As the

Solution 1:

floatting element should come first/ahead in code from element in the natural flux.

see (among others links you can find on search engines) : https://css-tricks.com/all-about-floats/

body {
  background-color: #DCDBD9;
  color: #2C2C2C;
  font: normal 100% Cambria, Georgia, serif;
}
h1 {
  font-size: 1.5em;
  font-style: italic;
  font-weight: normal;
}
h1a {
  color: #747474;
  font: bold 0.45833em Calibri, Optima, Arial, sans-serif;
  letter-spacing: 0.15em;
  text-transform: : uppercase;
  text-decoration: none;
}
#page {
  margin: 36px auto;
  width: 90%;
}
#nav {
  float: right;
  /*padding: 42px 0 0 30px;*/
}
#navli {
  float: left;
  margin: 0005px;
}
.blog {
  clear: both;
  margin: 50px auto 53px;
  width: 93.75%;
}
.blog.main {
  float: left;
  width: 62.88%;
  /* 566px / 900px */
}
.blog.other {
  float: right;
  width: 36.77%;
  /* 331px / 900px */
}
.lede {
  padding: 0.8em5.333%;
}
.recent-entries {
  margin: 0 auto;
  width: 69.788%;
  /* 231 / 331px */
}
.article {
  padding: 40px8.480%;
}
.date {
  float: left;
  margin-left: -17.088%;
  /* 81px / 474px */width: 14.55%;
  /* 69px / 474px */border: 1px solid black;
  border-radius: 2px;
  padding: 0.59%;
  transition-property: background;
  transition-duration: 0.3s;
  transition-timing-function: ease;
}
.date:hover {
  background: #9c3;
}
img,
embed,
object,
video {
  max-width: 100%;
}
.figure {
  float: right;
  margin-bottom: 0.5em;
  margin-left: 2.531%;
  /* 12px / 474px */width: 48.734%;
  /* 231px / 474px */
}
h2 {
  color: #F90B6D;
  font-family: 'Open Sans', sans-serif;
  font-size: 1.2em;
  font-weight: 300;
}
p {
  color: #222;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.9em;
  font-weight: 400;
}
<!--  <h1> This is the top header! <a href="#"> Read More </a> </h1> --><divid="page"><ulid="nav"><li><ahref="#">About me</a></li><li><ahref="#">About Blog</a></li><li><ahref="#">Stuff</a></li><li><ahref="#">Junk Stuff</a></li></ul><divclass="blog section"><h1class="lede">Responsive Blog </h1><divclass="main"><divclass="article"><div><divclass="date">
            1 Sept 2015
          </div><divclass="figure"><p><imgsrc="http://dummyimage.com/290x400&text=Dont-Forget-To-Follow-Up"alt=""><bclass="figcaption">Remember This</b></p></div><h2> What is Lorem Ipsum ?</h2><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages , and more recently
            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div><divclass="date">
          5 Sept 2015
        </div><h2> Where does it comes from ? </h2><p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked
          up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus
          Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from
          a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original
          form, accompanied by English versions from the 1914 translation by H. Rackham.</p></div></div><!--/end.main --><divclass="other"><p>Recent Enteries</p><divclass="recent-entries"><p>1.Simply First Entry</p><p>2. Simply second Entry</p></div></div><!-- /end .other --></div><!--/end .blog.section --></div><!-- /end #page-->

Solution 2:

Each HTML element has got a display value which defines how the element is displayed. This value for most elements is block or inline; block elements always start on a new line and take up the full width available while inline elements stay on the same line and take only the amount of space they need. <p> elements fall within the block elements class while <img> elements fall in the inline one.

For further explanations and example take a look here W3C School - HTML Block and Inline Elements

Post a Comment for "Why Paragraph Don't Align Next To Image In Html?"