Search code examples
jquerycssspacing

remove spacing from css <em> tag


I'm using the em tag on a web app to high light when a certain event happens and incasing the text in <em></em> and using css to highlight the background green and display as a block so it creates a green section of text; however, <em></em> is adding space in between my lines, and I'm not sure how to get rid of it. line-height doesn't seem to work, and the spacing is fine without the <em></em> brackets.

Solution

You're right, I should have included the code. I thought it would be an easy answer and after looking it over in the Element section of Development Tools, I didn't see any margins or padding that would cause it. I've figured out that it is because in my non code, I put a after each line, but when I incase the part I want in the code, it effectively adds its own break at the end to go to the next line, so the extra spacing was because I left in , once removed, it worked fine. I'll post my code below for reference.

Original code:

$('#Waiting_Name').html($('#Waiting_Name').html() + "<em>" + data[i].Patient_Name + "</em></br>");

New code:

$('#Waiting_Name').html($('#Waiting_Name').html() + "<em>" + data[i].Patient_Name + "</em>");

Solution

  • I'm using the em tag on a web app to high light when a certain event happens and incasing the text in <em></em> and using css to highlight the background green and display as a block so it creates a green section of text; however, <em></em> is adding space in between my lines, and I'm not sure how to get rid of it. line-height doesn't seem to work, and the spacing is fine without the <em></em> brackets.

    Solution

    You're right, I should have included the code. I thought it would be an easy answer and after looking it over in the Element section of Development Tools, I didn't see any margins or padding that would cause it. I've figured out that it is because in my non code, I put a after each line, but when I incase the part I want in the code, it effectively adds its own break at the end to go to the next line, so the extra spacing was because I left in , once removed, it worked fine. I'll post my code below for reference.

    Original code:

    $('#Waiting_Name').html($('#Waiting_Name').html() + "<em>" + data[i].Patient_Name + "</em></br>");
    

    New code:

    $('#Waiting_Name').html($('#Waiting_Name').html() + "<em>" + data[i].Patient_Name + "</em>");