6 min read


jQuery Mobile First Look

jQuery Mobile First Look

Discover the endless possibilities offered by jQuery Mobile for rapid Mobile Web Development

Trying to communicate and provide information in an effective way can be a little trickier when we are targeting mobile devices; their screens are relatively small (ridiculously small if we think about our 24 inch iMac resting on our office desk), and we have already understood that we cannot display content in the way we used to, back in the days when desktop computers were the only way to access data on the Internet.

With the advent of mobile browsing, new solutions had to be found.

The jQuery Mobile framework provides a number of tools, widgets, and components which are extremely helpful in formatting our content and make it look elegant and put-together even on our beloved smaller-screen devices – well, especially for them!

In fact, the difficulty in designing, formatting, and correctly showing a page on a mobile device is going to become a no-brainer using the set of elements jQuery Mobile provides in order to allow for an easy styling of our web application content.

How content is displayed

Yes, there is nothing wrong in just writing down what our website or web application is about in the HTML file. It’s always worked and always will.

The actual point here is taking advantage of the tools jQuery Mobile offers us to format our information, specifically for mobile devices.

For example, there are occasions in which the need for multiple columns may arise: we can use a layout grid, which is nothing more than some CSS-based columns.

Or, on a completely different note, we might just need to hide/show a block of content: collapsible blocks have been designed for this, and can be easily implemented in our site layout.

But before we begin analyzing any of the methods in which we are able to format our content according to our liking, we should take a look at how content is displayed in its basic HTML formatting.

Based upon the “light hand approach” (as they call it), jQuery Mobile lets the browser rendering take precedence over any other third-party styling, with exceptions made for the following little tweaks the framework applies to any page by default:

  • Adding a bit of padding for a better readability
  • Using the theming system to apply fonts and colors

This particular approach to styling by default should make the designers really happy, as they often find themselves fighting with preset colors schemes, default fonts, weird margin, and padding values and usually end up resetting everything and starting again from scratch.

Thankfully, the default padding value looks quite right and, as far as theming goes, we are able to easily customize (and create new) themes through CSS files and a theming framework which is extremely versatile and flexible.

Default HTML markup styling

So, what happens if we just write some HTML markup and want some text to be bold, emphasized, or hyper-linked? jQuery Mobile applies some basic styling to the elements and makes their look consistent with the simple and clean layout we have already seen in action.

The following screenshot represents how headings and standard paragraphs are displayed and generated by the following code:

 Default HTML markup styling

H1 Heading

H2 Heading

H3 Heading

H4 Heading

H5 Heading
H6 Heading

This is a paragraph. Lorem (bold) ipsum (emphasized) dolor (link) sit amet, consectetur adipiscing elit.

Blockquote containing a cite blockquote>

This is a paragraph. Lorem (bold) ipsum (emphasized) dolor (link) sit amet, consectetur adipiscing elit.

The result is shown in the following screenshot:

jQuery Mobile tutorial on Grid Layout Theming Content

Similarly, the following code produces a preview of what lists and tables look like:

 Default HTML markup styling

  • Unordered list item 1
  • Unordered list item 2
  • Unordered list item 3
  1. Ordered list item 1
  2. Ordered list item 2
  3. Ordered list item 3
Table caption
Name City Phone
Table foot
David Green New York City, NY 555-0123
Martha White Los Angels, CA 555-0188
Bobby Brown Washington, D.C. 555-0110

jQuery Mobile tutorial on Grid Layout Theming Content

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here