49

Ive got a block of text, and i want to write the authors name and date bellow it in small italics, so i put it in a <span> block and styled it, but i want to space the name out a little bit so i applided margin (also tried padding) to the block but it cant get it to work.

Ive made a jsfiddle of the issue - HERE

The html looks like

<p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa omnis obcaecati dolore reprehenderit praesentium.
<br><span>Author Name, Year</span>
</p> 

The CSS

p       {font-size:24px; font-weight: 300; -webkit-font-smoothing: subpixel-antialiased;}
p span  {font-size:16px; font-style: italic; margin-top:50px;}
sam
  • 9,486
  • 36
  • 109
  • 160

6 Answers6

67

Overall just add display:block; to your span. You can leave your html unchanged.

Demo

You can do it with the following css:

p {
    font-size:24px; 
    font-weight: 300; 
    -webkit-font-smoothing: subpixel-antialiased; 
    margin-top:0px;
}

p span {
    font-size:16px; 
    font-style: italic; 
    margin-top:20px; 
    padding-left:10px; 
    display:inline-block;
}
Peter Rasmussen
  • 16,474
  • 7
  • 46
  • 63
27

Add this style to your span:

position:relative; 
top: 10px;

Demo: http://jsfiddle.net/BqTUS/3/

Eli
  • 14,779
  • 5
  • 59
  • 77
11

Try in html:

style="display: inline-block; margin-top: 50px;"

or in css:

display: inline-block;
margin-top: 50px;
MagTun
  • 5,619
  • 5
  • 63
  • 104
2

Use div instead of span, or add display: block; to your css style for the span tag.

Floremin
  • 3,969
  • 15
  • 20
2

Try line-height like I've done here: http://jsfiddle.net/BqTUS/5/

gaynorvader
  • 2,619
  • 3
  • 18
  • 32
  • 2
    By adding `line-height` you won't effect the rest of the flow of your html document. Adding `inline-block` to your element will be force to follow width constraints if addition elements where to follow to the right of your span. You stated you wanted to "space the name out a little bit so i applied margin". Margins will only apply to TOP, BOTTOM etc of your element. Whereas line-height will keep the spacing correct even when your text wraps to the next line. I've 1 UP'd this as the answer as it is technically correct if the text wraps and you if need space between names and each name line. – phanf Sep 03 '15 at 20:36
0

JSFiddle

HTML:

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa omnis obcaecati dolore reprehenderit praesentium. Nisi eius deleniti voluptates quis esse deserunt magni eum commodi nostrum facere pariatur sed eos voluptatum?

</p><span class="small-text">George Nelson 1955</span>

CSS:

p       {font-size:24px; font-weight: 300; -webkit-font-smoothing: subpixel-antialiased;}
p span  {font-size:16px; font-style: italic; margin-top:50px;}

.small-text{
font-size: 12px;
font-style: italic;
}
brbcoding
  • 13,378
  • 2
  • 37
  • 51