473,837 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Centered fragment in a paragraph

I'm trying to display a paragraph that has a centered

such as this one,

in the middle of the paragraph. An example is the section
"End of semester project" on my course-page


=============== =============== =============== ===============
In the past, I have used this structure:

<p>I'm trying to display a paragraph that has a centered
<center>such as this one,</center>
in the middle of the paragraph.</p>

This, or with the <centerreplac ed by

<div align="center"> .

In both cases, the text displays the way I would like.
Alas, the page doesn't validate completely at


Rather, I get this error:

Error Line 377, Column 7: end tag for
element "P" which is not open.

My *guess* as to why this is happening is that the
presence a of a block element (either "div" or "center")
inside of a <pis causing a </pto be inserted before
the block element.

=============== =============== =============== ===============

It would not be disaster if I had to typeset this as

<p>I'm trying to display a paragraph that has a centered
<center>such as this one,</center>
<p>in the middle of the paragraph.</p>

but I'm wondering if I can

* typeset it as a single paragraph, the way I think of it,

* have a centered fragment (like a "displayed equation" in
a mathematics textbook)

* have the document validate.

Prof. Jonathan King (gentsquash)
Mathematics dept, Univ. of Florida
Jun 27 '08 #1
3 2321
On Jun 3, 4:32 pm, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
Scripsit gentsqu...@gmai l.com:
In the past, I have used this structure:
<p>I'm trying to display a paragraph that has a centered
<center>such as this one,</center>
in the middle of the paragraph.</p>

While it may give the impression of working, it is invalid
markup, as you have noted. It's not just a theoretical issue,
since you get a wrong document tree in the Document Object
Model. For example, if you assign a CSS rule that applies to
p elements, it will only be applied to the part that precedes
the <centertag, since by HTML parsing rules, the paragraph
ends there.
Ah --I'd likely get bitten by that sometime in the future. Ta.
... You can use <span>, with a suitable class attribute, for
the text you wish to center, and use CSS for displaying the
span element (which is inline by HTML rules, hence allowed
inside a p element) ... with CSS code like ...

.special { display: block; text-align: center; }
Very nice. Thank you.

I realize now that I can use

<style type="text/css">
.jukkaspecial { display: block;
margin-left: 7em;
margin-top: 0.8em;
margin-bottom: 0.8em;
width: 19em;

and get the effect

I'm trying to display a paragraph that has a centered phrase,

such as this one, which is actually
quite a bit longer than I realized at
first blush, and its sesquipedalian
nature is unusual

in the middle of the paragraph, but what the Hey!
\______________ _______________ _______________ ____________/

of a LaTeX macro that I have often used:

The LaTeX macro I call "\display". Is there any reason I
shouldn't call the CSS "jukkaspeci al" class by the name
"display", so that I'll remember what it does? My concern
is that "display" is also meaningful in CSS.

Sincerely, --gentsquash
Jun 27 '08 #2
Scripsit ge********@gmai l.com:
The LaTeX macro I call "\display". Is there any reason I
shouldn't call the CSS "jukkaspeci al" class by the name
"display", so that I'll remember what it does?
Generally, class names should reflect the meaning of elements. For
example, if the fragment is a mathematical formula, class="formula"
would be suitable.

In LaTeX, the approach is different in principle: you have formatting
commands (TeX primitives), and you define macros in terms of them. In
practice, it is rather the other way around: LaTeX macros often have
meaningful, semantically suggestive names, whereas HTML class names are
often macro-like.

In both approaches, semantically meaningful names are usually better
than purely presentation-oriented. They make the code easier to
understand (e.g., a few years later when you need to read it) and easier
to modify. Moreover, you may later wish to change the presentation
completely (e.g., for a different presentation medium);
presentation-oriented names would look rather silly after that!

This leaves the problem that you might wish to use the same rendering
for semantically different things, like formulas and news extracts. But
in CSS, this is easily managed. You could use class="formula" and
class="news" in HTML and a rule like

..formula, .news { ... }

in CSS. You can then later easily differentiate the renderings if you
like, e.g. by adding rules that apply to just one of those classes.
My concern
is that "display" is also meaningful in CSS.
That's not a problem. There are no reserved names for classes, i.e.
anything that syntactically matches the pattern of class names can be
used, with no keywords extracted from the available name space. (The
so-called HTML 5 activity tries to change this, but this is just one of
its fundamental flaws.)

In CSS, you use a class name prefixed with a period ".", so ".display"
cannot possibly be mistaken for the property name "display" by a CSS
parser. Moreover, property names appear in CSS in certain contexts only
(inside curly braces "{...}" or in a style="..." attribute, where class
names cannot appear), and even this would be sufficient.

Jukka K. Korpela ("Yucca")

Jun 27 '08 #3
In comp.infosystem s.www.authoring.html message <ad8a6c7e-501d-4faa-961c-
04**********@e5 3g2000hsa.googl egroups.com>, Tue, 3 Jun 2008 12:53:35,
ge********@gmai l.com posted:
>I'm trying to display a paragraph that has a centered

such as this one,

in the middle of the paragraph.
Maybe with CSS
span.EQN { display: block; text-align: center; } /* Not IE4 */

(c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 7.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelig ht.net/minitrue/unsupported.
Jun 27 '08 #4

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

Similar topics

by: Stuart Baker | last post by:
I just added session support to a web site and the URL's that contain a #fragment no longer function. Is there a delimiter that I can add following the #fragment that will tell the browser that the SID information is not part of the #fragment? Thanks in advance. Stuart Baker
by: VRandy | last post by:
Example: http://pages.prodigy.net/randyv/centerprb.htm The desired effect is a fixed width left margin with a fixed width div centered in the right side. If the browser is resized to become very narrow (less than 640px in this example), the right side centered div should stop at the margin and horizontal scroll bar appear as the window gets extremely narrow. IE6 and Opera 4.11 display all the examples the same way. The top row is a...
by: David Winter | last post by:
This is a totally trivial CSS problem, I'm sure, but I don't get it. I want a centered DIV with a fixed width between two other DIVs that should fill the rest of the window/viewport (= 100%). How do I achieve this? I tried width:auto for the buffer DIVs, but it didn't work. This should at least work in IE 5.5 and Opera. A totally standards-compliant solution would be appreciated, of course ... :/ This is waht I have:
by: Mimo Zus | last post by:
I'm hoping that someone can explain what's going on; better yet provide a workaround. I'm designing a centered CSS site based on a 550 pixel wide vertical background image. Onto this background I built a two column layout with nested navigation and content divs. The background image is centered via "background: ... center;", the divs are centered over it via "margin: 0 auto 0 auto;". The problem I'm having in IE6 is inconsistent...
by: Stian Lund | last post by:
Hello, I've been struggling with this problem for a while now, so I though I'd get some input from anyone more skilled with CSS than I am. I'm actually trying to accomplish two things with this: 1. Create a floated image with text around, with a caption centered underneath. Image size can be varied but the caption needs to have a fixed size to make it break correctly I think. I also need the image to resize automatically when the...
by: Gustaf | last post by:
I'm trying to grasp this little passage from the XBRL spec: "The xlink:href attribute MUST be a URI. The URI MUST point to an XML document or to one or more XML fragments within an XML document. If the URI is relative, it MUST be resolved to obtain an absolute URI as specified in XML Base specification ." I guess they really mean "URI reference" and not "URI" in the formal sense. But anyway, consider this document:
by: larzeb2000 | last post by:
I have constructed a css stylesheet which has a centered layout. The wrapper div is defined as 1000px. It contains a header div for the entire wrapper width, and a left sidebar div and a content div on the right. Everything appears as I would expect. I have made a homepage with nothing in the content area, and another page with the content filled so that the vertical scroll bar is present. When I'm in IE6 and go between the two pages,...
by: Troy Piggins | last post by:
If I use the code: ----- <div style="text-align: center;"> <a href="photos.php?img=xx1.jpg"> <img src="xx1.jpg" style="padding: 10px;" /> </a> <a href="photos.php?img=xx2.jpg">
by: TheLongshot | last post by:
I just recently converted a few pages of my application to using master pages. Problem is, in all of my content pages, the contents are centered. I can't figure out why. The markup in the content page seems to ignore any attempts to manually align right. So what's the deal?
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,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.