|
Home>HTML
and CSS>
HTML and CSS
Website designers often use JavaScript
to expose dynamic content to visitors. Sadly, updating JavaScript
can be painful at best. CSS can help to overcome JavaScript's
limitations -- and the two together open up some lovely
possibilities. Usually we retrieve some database records with
dynamic information, properly format them for visual presentation,
and finally deliver the visual output to the user’s browser when
we’re dealing with the common task of fetching some dynamic content
to our Web pages to make them more appealing and juicy to visitors.
We congratulate ourselves for that efficient and versatile process;
it’s really a nice and straightforward task.
Most well-structured websites heavily rely on database contents, at
times, it’s necessary and even desirable to expose some dynamic
content based on client-side techniques. JavaScript becomes
extremely handy when we’re dealing with this scenario, since it is
used extensively for displaying content on demand in our Web pages.
However, one of the great drawbacks of using JavaScript to perform
that task is that all of the contents have to be stored in
variables, within the scripts. This approach makes adding and
updating content a very painful and annoying experience.
With the help of CSS, we can improve this situation. CSS helps us to
break out of some of the intrinsic JavaScript limitations, so that
common HTML content can be displayed dynamically accordingly to the
logic of the master script, without having to deal directly with
JavaScript variables. This way, updating or adding content to our
Web page can be a more pleasant process.
You should preload regular HTML content by hiding it from view
initially, utilizing the well supported CSS attribute display: none.
By implementing this attribute, we can selectively hide different
sections of Web pages, and then programmatically bring them back to
life, according to the script’s logic. With the core idea in hand,
we’ll see this CSS technique and knowing how powerful it can be.
|