Line Height Problems for Layout Designers and the Switch to HTML 5

 

I received a message earlier from a layout designer regarding the line heights in their designs no longer functioning the way they were originally intended. I looked into the issue and I found that it stems from the site recently switching from XHTML to HTML 5. I've discussed my findings with the layout designer and I'm going to re-post my response below for the rest of you that may also be having similar issues.

I figured out your line-height issue but you're not going to like the solution depending on how you do your layouts.
 
I'm not sure as to your level of HTML and CSS knowledge but I'll make some assumptions. I recently changed the HTML Doctype of the website from XHTML 1.0 to HTML 5 for the reason that HTML 5 has new features that the site can take advantage of. It shouldn't have broken any design aspects on the site as long as the design was coded properly.
 
Looking at your code, it seems that your line-height attribute is located in a span tag which is an inline element when it should be in a block element like a div or a p tag. In HTML 5 and strict HTML 4 Doctypes, the line-height will inherit the line-height attribute of the closest block level element. The way to resolve your line-height issues is to simply turn your span tags into div tags wherever a line-height attribute is defined. This is the correct way of defining HTML tags whereas HTML Doctypes prior to the new HTML 5 standard was much less strict.
 
 
As for the reason for sticking with HTML 5, it is so that we can use more powerful browser features especially in the area of mobile web design. There are certain things that are simply only available in HTML 5 like websockets which we can use for dynamic alerts without needing to refresh the page, for example, or sending an alert out to a mobile device whenever they receive a message.
 
Hope that helps a little.
 
TL;DR Your line-height attribute is in a span when it should be in a div element. Change that span to a div and you should be fine. Even easier, you can simply set the line height attribute for your whole design by wrapping your entire code in a div and set the line height attribute for that. You can do that by typing <div style="line-height:10px"> at the very beginning then type </div> at the very end in your source code.
 
By the way, if you're serious about designing layouts, hand code your layout in a dedicated HTML/CSS editor which can help you out with syntax and placement immensely. You can paste your results on the editor here on AFF when you're done. Never have your work solely on AFF; make sure you have backup copies on your computer. There are tons of editors out there but my recommendations are below:
 
Windows: Notepad++ (lightweight)
Mac: TextMate (lightweight)
Cross-Platform: Aptana (Full IDE), NetBeans (Full IDE), Sublime (lightweight)
 
Many designers use Notepad++ or TextMate so I whole-heartedly recommend either. Use Full IDEs if you're also a programmer.

Comments

You must be logged in to comment
92Storyteller
#1
This is very helpful >.< THANK YOU!!!

I've been using html to post on aff and now I see why it doesn't come out right sometimes
JustagurlSpring
#2
As Captain Avery said "I'm confused." but y'know someone like the Doctor fixed it so it's all right. I think. Still confused. But I'm thinking.
contaegious
#3
oh this was very informational. it'll definitely help
thank you very much! o/
-dreamcatcher
#4
oh my god.
T_____T </3
LovesYoseob
#5
I feel like I got half of that at the very least. But... you hinted at new mobile features?? :D
daggerisms
#6
that sad yet beautiful moment when the time spent messing with your tumblr theme has paid off and you know just what it is that was said/meant in this blog lol
Zevlin22
#7
I am....entirely confused. Am consulting my friend who does programming for some insight
milaus
#8
I still don't really get it
When I replace the span with div in the source where the line-height is located,
it only gets messed up with the line adjustment and font size/color