Asked  7 Months ago    Answers:  5   Viewed   26 times

You can set the width of inline elements like <span>, <em> and <strong>, but you won’t notice any effect until you position them.

a) I thought the width of inline an inline element can’t be set?

b) Assuming width can be set - we won’t notice any effects ( thus the width we specify ) until we position inline element. Position how/where?

c) Why is the width of inline elements apparent only when we “position” them?

 Answers

77

As others have mentioned, setting the width (or some other position-related property) of an inline element will cause the browser to then display the element as a block element.

You can explicitly declare this sort of behavior through using the CSS display property. The most common settings are display: inline (default), display: block, and display: none.
A full reference for the display property is available here.

However, it should be noted that the HTML 4.01 specification discourages the use of "overriding the conventional interpretation of HTML elements":

Style sheets provide the means to specify the rendering of arbitrary elements, including whether an element is rendered as block or inline. In some cases, such as an inline style for list elements, this may be appropriate, but generally speaking, authors are discouraged from overriding the conventional interpretation of HTML elements in this way.

Tuesday, June 1, 2021
 
elias
answered 7 Months ago
32

It is valid in XHTML. It is not HTML-Compatible so likely to break in a document served as text/html. Having a link with no content is bad practise (background images are not content (which is why there is no equivalent to the alt attribute)).

Saturday, August 14, 2021
 
Arman
answered 4 Months ago
34

The following assumes that my_height and my_width returned by your functions are plain numbers:

document.getElementById('mygraph').style.height = my_height + "px";
document.getElementById('mygraph').style.width = my_width + "px";
Friday, August 27, 2021
 
turik
answered 3 Months ago
15

With the handle of the menu, you can cycle through the menu items and call SetMenuItemInfo, indicating that you want to owner-draw the menu items. When you do this, the window that the menu is attached to will receive the WM_MEASUREITEM message, which you would then respond to by setting the dimensions required for the menu. It is here you can set your width.

Of course, this means you have to subclass the windows message handler for the window that contains the menu.

Wednesday, September 1, 2021
 
HexaGridBrain
answered 3 Months ago
87

They only application I know of that can possibly convert HTML/CSS3 to good quality PDF is PrinceXML. (And it is my impression, that Google licensed and utilizes their code somehow in GoogleDocs for PDF export.)

However, this is a commercial application, and I think it comes with a hefty price tag.

One of it's leading lights is Håkon Lie, who is also behind all the technical achievements of the Opera web browser.

Here is a 2 years old Google Tech Talks video where Lie outlines some of the technologie behind PrinceXML:

  • http://www.youtube.com/watch?v=vcXUrNSvjhU
Thursday, November 18, 2021
 
cᴏʟᴅsᴘᴇᴇᴅ
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share