What is a div for and how does it differ from a span?

This forum is for all Flare issues related to styles, stylesheets and XML.

What is a div for and how does it differ from a span?

Postby bwofficer on Thu Jun 23, 2022 3:08 am

What is a div for and how does it differ from a span? They both seem to be for creating a chunk of content that you can then style.

I've sussed that when I highlight some text in the topic and apply a style to it, Flare puts span tags in. So when would I use a div? My background is in paper-based documentation. Even having adopted Flare I'm only using it to create PDFs, not website content, so my knowledge of html and suchlike is sketchy at best. Flare help seems to assume I already know what a div is, but given my background I don't.

I want to understand this, because I find that the better I understand why something is the way it is the less likely I am to misapply it and make a stupid numpty mistake.
bwofficer
Propeller Head
 
Posts: 34
Joined: Tue May 12, 2020 2:16 am

Re: What is a div for and how does it differ from a span?

Postby ajturnersurrey on Thu Jun 23, 2022 6:23 am

Think of a div as a container for a whole paragraph or more. Doing pdf documents I often put a div around a combination of figure and figure label, or preamble plus table. I then apply PrintSupport settings to the div style to avoid column, frame or page breaks within the div. From a css point of view a div is a block level element, so they are quite controllable. They get used in html to position text blocks in particular places. I often use divs to apply a condition to set of paragraphs that should only appear, say, in the online help not the pdf.

Think of a span as a way of identifying some tiny part of a sentence that needs special treatment, such as a word to highlight in red. I apply a span style to Note: or CAUTION: to give me the bold and capitalisation I want, so that it can be easily changed when the company style changes. From a css point of view it is an inline container, so it doesn't have as many properties that can be set as a div, and you can't use it to position anything.
ajturnersurrey
Sr. Propeller Head
 
Posts: 339
Joined: Fri Nov 05, 2010 3:30 am

Re: What is a div for and how does it differ from a span?

Postby bwofficer on Thu Jun 23, 2022 6:28 am

Thanks. That makes sense. Divs can be positioned. Spans have to remain inline.
bwofficer
Propeller Head
 
Posts: 34
Joined: Tue May 12, 2020 2:16 am

Re: What is a div for and how does it differ from a span?

Postby Nita Beck on Thu Jun 23, 2022 12:18 pm

As noted above, the most salient things about a div are that (1) it is a container able to hold other tags such as paragraphs, images, lists, tables, headings, even other divs and that (2) it can be formatted. For example, many authors use divs to contain notes or other alerts. Instead of having just a p.Note style, one can have a div.Note style that will give the div, say, a border, a background color, even a background image, a given size, a given position, and so forth. That div.Note can then hold anything needed for a particular note.
Nita
Image
Content Strategist / Information Architect / Flare Consultant: http://beck-communications.com
Manager, Rochester Flare User Group: http://www.facebook.com/RochesterFlareUserGroup
Nita Beck
Senior Propellus Maximus
 
Posts: 3507
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 6 guests