473,761 Members | 4,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Container in text flow needs to have block elements

I'm taking a stab at making CSS sparklines - see
http://www.edwardtufte.com/bboard/q-...ic_id=1&topic=

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Sparklin es</title>
<style type="text/css">
..dot {
border-bottom: 1px solid #777777;
float: left;
width: 3px;
}

#cont {
height: 12px;
width: 60px;
background-color: #dddddd;
}
</style>
<script type="text/javascript">
window.onload = function() {
var ht = parseInt(Math.r andom()*10);
var cont = document.getEle mentById('cont' );
for (var i=0; i<20; i++) {
ht += parseInt(Math.r andom()*3)-1;
ht = Math.abs(Math.m in(ht, 9));
var d = document.create Element('div');
d.style.height = ht+'px';
d.className = 'dot';
d.appendChild(d ocument.createT extNode(' '));
cont.appendChil d(d);
}
};
</script>
</head>
<body><p>a sparkline is a graph
<span id="cont"></spanthat can be embedded within the text of a
paragraph</p>
</body>
</html>

What I want is the span to be flowed in with the text of the paragraph.
This works properly with IE; unfortunately, Firefox sees the nested,
floated divs (DHTML-generated code):

<p>a sparkline is a graph
<span id="cont">
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 8px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 8px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
</spanthat can be embedded within the text of a paragraph</p>

and makes everything containing it block-level. So the text will flow
around it (as with a floated image), but not incorporate it between two
specific words.

Does anyone know of a solution to accomplish this? Getting an
inline-level element to contain block-level elements? Or perhaps a way
to not use "float" and get the same effect? I prefer a CSS-only
solution where possible; the solutions you find on Google do something
similar but with 1px-wide gifs instead of DIVs.

Thanks,

David

Dec 1 '06 #1
3 3232

David Golightly wrote:
<span id="cont">
<div class="dot" style="height: 9px;"</div>
Your HTML is invalid here. There's never an excuse for that, you can
stick with valid HTML and change the CSS display property as needed.
Does anyone know of a solution to accomplish this? Getting an
inline-level element to contain block-level elements?
Use display: inline-block; This is what it's meant for, but as yet the
implementations haven't caught up with the CSS spec.

I like these sparklines, but the last attempts I made at using them did
it with embedded SVG instead. Worked beautifully, but I'd sacrificed
any thoughts of widespread browser support.

Dec 1 '06 #2
VK

David Golightly wrote:
What I want is the span to be flowed in with the text of the paragraph.
This works properly with IE; unfortunately, Firefox sees the nested,
floated divs (DHTML-generated code):

<p>a sparkline is a graph
<span id="cont">
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 8px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 9px;"</div>
<div class="dot" style="height: 8px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 7px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
<div class="dot" style="height: 6px;"</div>
</spanthat can be embedded within the text of a paragraph</p>

and makes everything containing it block-level. So the text will flow
around it (as with a floated image), but not incorporate it between two
specific words.
It is impossible to insert block elements (say DIV) into P: no one of
ever existed browsers will allow it. P block automatically closes up
before any other block element regardless of where the closing </pis.
This behavior is by specs.

As suggested you can use inline elements (say SPAN) and redefine
display to inline-block. Gecko doesn't have this display style but it
has -moz-inline-box instead. -moz-inline-box is still under development
(means use with care) but for simple things it is pretty stable. So it
could be:
SPAN.sparkline {
display: -moz-inline-box;
display: inline-block;
/* other styling */
}

Dec 1 '06 #3

Andy Dingley wrote:
David Golightly wrote:
<span id="cont">
<div class="dot" style="height: 9px;"</div>

Your HTML is invalid here. There's never an excuse for that, you can
stick with valid HTML and change the CSS display property as needed.
Does anyone know of a solution to accomplish this? Getting an
inline-level element to contain block-level elements?

Use display: inline-block; This is what it's meant for, but as yet the
implementations haven't caught up with the CSS spec.

I like these sparklines, but the last attempts I made at using them did
it with embedded SVG instead. Worked beautifully, but I'd sacrificed
any thoughts of widespread browser support.
Hm, well, thanks for the suggestions, but none of them actually solve
the problem. display: inline-block would be great but it actually does
nothing different from display: block in current browsers. I'd like to
avoid using a full-blown cross-browser inline graphics library
(SVG+VML) to do this, and any non-cross-browser solution is pretty much
out of the question. The capabilities of CSS to easily tailor the look
of the sparklines to the page is what I'm after.

Dec 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2143
by: Gordon - Adelphia | last post by:
I have a question regarding xhtml. Why, why, why does the ELEMENT <body> allow “unblocked” text. HTML does not (though, most browsers will render). Xhtml (transitional) however allows text nodes (PCDATA). All of HTML 4, xhtml – transitional, and xhtml-strict allow <div> to contain “unblocked” text. Does anybody know why – I’m looking for the philosophy behind allowing such. I’m in the process of encapsulating xhtml mark-up in content...
11
7240
by: Robert Bowen | last post by:
Hello all. I have been given mock-ups (in static HTML) of some pages for a site I am working on. The client would like these pages to look exactly as they do now. The problem is that the content is dynamic, it comes from a database. My question -- with CSS (because with HTML tables I don't think it's possible) how can I make my text "flow" in two columns? eg. If there are 100 lines of content, I would like 50 to be in the 1st column, and...
5
3810
by: Miyra | last post by:
Hi. I'm working with an app that uses exceptions for control flow. These are code blocks where exceptions are thrown/caught regularly. A couple hundred exceptions occur per hour and they're caught close to the point of origination. I'm trying to decide whether to refactor... What is the cost of throwing an exception in the CLR - relative to, say, a conditional statement? Are we taking talking 1+ orders of magnitude? Is there...
2
2843
by: zeyais | last post by:
I am using ASP.net (should be transparent in this case). The page is generated alright. The page has fieldset, divs and tables and other HTML elements like text box, drop downs etc; all are standards. Also, the page is formatted/decorated using CSS. Here is the issue: HTML generated is alright. Except: 1. IE the text is clipped instead of wrapping the text around inside the fieldset/div. Even the right side of the fieldsets border is...
3
4467
by: ianv2 | last post by:
Hi I have a div which contains my local navigation bar, which has a blue background and is next to the content div, at the moment however this blue background colour stops after the unordered list ? I would like the background colour to fill the entrire length of the localnav div How is this achieved with CSS?
18
2954
by: Hunk | last post by:
Would like some advice on the fillowing I have a sorted list of items on which i require to search and retrieve the said item and also modify an item based on its identity. I think an Map stl container would be most suited. Am i correct in my assumptions Problem Reocrds are already stored with a unique identity in a binary format.The structure is roughly ----------------------
1
5932
by: Miked | last post by:
Hello: I'm relatively new to CSS, and I'm doing a site where I don't want to use any tables. I've gotten pretty far, and the site has the layout I want. My only problem is that I'm using the flot positional paremter a lot on containers, and it really seems to do what I want. Except when I put other containers in these containers, they don't expand vertically like I want. Here's the stylesheet:
36
2037
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are there any other no-overhead ways that a contained class can access its container? The obvious choice of passing (a pointer or a reference to the container) to the contained class is not a no-overhead solution, it requires both memory and time. I am...
8
2255
by: Jonathan Sachs | last post by:
I'm trying to compose a list of items, each of which consists of text that wraps around a picture at the left margin. The examples I have seen tell me to do it like this: <p><img src="xxxx.jpg" align="left" width=nn height=nn>zzz zzzzz zz zzzzz...</p> In my case, since the wrapped text includes a headline, I assume I am supposed to do this:
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.